10-10-2013 05:37 AM
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 ?
10-10-2013 05:52 AM
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?
10-10-2013 07:15 AM - edited 10-10-2013 07:39 AM
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.
10-10-2013 07:36 AM
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?
10-10-2013 07:41 AM
10-10-2013 08:07 AM
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.