I have an app for WP8 and I would like to generate the reference to the services to call it synchronous instead of asynchronous. I need to make sure that one step is completed before start the second step.
Is there any way to do this ?
I've try to generate the methods sync instead of asynchronous but this option is not allowed in VS2013.
Regards
You can achieve, what you have mentioned, by using async/await keywords too, what you have to do is await
the first method before calling the next method. That's it ( provided Step1 is properly implemented - you got your all the required stuff done for the next step to be taken ).
Suppose :-
Step1 method :-
public async Task Step1()
{
...
}
Step2 method :-
public async Task Step2()
{
...
}
Now you want to call the Step2
only after completing of Step1
.So, Just call them in order by awaiting the Step1 method(Task)
Public async Task/Void RunStep2AfterStep1()
{
await Step1();
// you will only get here only when you Step1() is completed successfully.
await Step2();
}
The below Async/Await helper Image give you proper flow of async/await.
Note :- Don't try to avoid the Async/Await they are much more powerful than you think, and if you think your requirement can't be fulfilled without them. Then, I think, you need to explore much.
Thanks :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.