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
New Developer
Posts: 20
Registered: ‎03-23-2014
My Device: z10
My Carrier: fido

Re: How can i send http request sequentially with QNetworkAccessManager?

well, i am awared that i can put shipItem() in the slot. However, my point is that in the asynchonous program is it normal that we have to chain funtions after functions (postPayment(), sendInvoice(), shipPackage(), notifyClient()...) if those function must be done in sequence/synchronously? Is there no other way to structure the code with 1 function driving the process?

 

For example, in a synchronous program we have something like this(psudo):

 

//Note that this method laid a clear plan what should happen
execMonthlyRoutine(){ postPayment(); sendInvoice(); shipPackage(); notifyClient(); } postPayment(){ //send request //wait for reply (IO blocking) } sendInvoice(){ //send request //wait for reply (IO blocking) } shipPackage(){ //send request //wait for reply (IO blocking) } notifyClient(){ //send request //wait for reply (IO blocking) }

 

 

But in an async program this is what i got:

//Note that this method has no idea what gona happen, because the steps is chained
execMonthlyRoutine(){ //send request connect(response, SIGNAL(finished(QNetworkReply*), this, SLOT(postPayment())); } postPayment(){ //send request connect(response, SIGNAL(finished(QNetworkReply*), this, SLOT(sendInvoice())); } sendInvoice(){ //send request connect(response, SIGNAL(finished(QNetworkReply*), this, SLOT(shipPackage())); } shipPackage(){ //send request connect(response, SIGNAL(finished(QNetworkReply*), this, SLOT(notifyClient())); } notifyClient(){ //done, update UI }

 

 I am new to asyn programming, so my question may sound retarded Smiley Very Happy