Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Regular Contributor
Posts: 63
Registered: ‎08-05-2013
My Device: Blackberry-10 webworks
My Carrier: zcon

Stop function execution till another function get values

Hi,

I am calling getInternetDataUsage() function from generateXML() function. In getInternetDataUsage function I have used ifconfig command ,so output is came when readyReadStandardOutput() signal is generated.

Now my problem is when I called getInternetDataUsage from generateXML function ,control is came back to generateXML after executing getInternetDataUsage() and not wait for getting values of data usage.

Is there any way to pause the generateXML function and resume it when ifconfig output is ready ?

Retired
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Stop function execution till another function get values

I think you should change your design. This is asynchronous and this is why a signal is provided to indicate when your process execution has completed. Rather than try to wait until you are notified via the signal that this is the case, why not connect that signal to a slot and implement whatever code you currently have in generateXML that is dependent on this, in the slot?

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Regular Contributor
Posts: 63
Registered: ‎08-05-2013
My Device: Blackberry-10 webworks
My Carrier: zcon

Re: Stop function execution till another function get values

[ Edited ]

Hey,

Thanks for your reply.

Insted of calling getInternetDataUsage() function from generateXML() function I will first call  getInternetDataUsage()

and after generating readyReadStandardOutput() signal I will call generateXML(). So I will get all the values before generating the xml.  

Regular Contributor
Posts: 63
Registered: ‎08-05-2013
My Device: Blackberry-10 webworks
My Carrier: zcon

Re: Stop function execution till another function get values

Hey,

One more problem is there....

While generating xml I need to pass SMS count and voice data also. If I called GenerateXML from a function which will called when readyReadStandardOutput() signal is generated, it will be OK till I have internet connection but what if network is currently not present. Then I will not able to send SMS and voice data too.  

Is there any way through which I can pause generateXML function till my readyReadStandardOutput signal is not generated?

Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Stop function execution till another function get values

have a failed signal as well
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Retired
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Stop function execution till another function get values

OK, so your XML generation is dependent upon the successful completion of a number of other, asynchronous actions.

 

I would process like this:

 

- have a central class (suggest a singleton) that implements slots that you connect to the signals that indicate your dependent actions finishing

- in this class, keep track of the status of each dependency (e.g. a bool for each signal/slow which you set to true when it is called)

- in each slot have logic which says "if all flags set then all dependencies have been satisfied so now I can generate my XML".

 

So there's no need to pause execution of your method, instead you just ensure that you do not execute it until all your dependencies have been satisfied.

 

You'll need to think about some logic which resets the flags completely as well.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim