c# - How to emulate Task.Wait() in WinRT? -


i have read if wait() called on task before started, taskscheduler may attempt start task inline on thread calling wait(). undesirable me because trying guarantee order of execution of operations, , inline call may screw up. basically, exposing 2 ways queue items (one async , 1 sync). sync method using wait() wait result of operation once entered queue on thread , executed, have switched this:

while(t.status == taskstatus.created)     task.delay(10).wait();  t.wait(); 

this looks bit scary, , smelly, there way wait task finish without scheduler attempting schedule inline? waiting seems work, i'd rather use alternative method if there one. i'm restricted windows runtime library.

@pako suggested in comments, , seems simple enough solution combine continuewith; synchronously wait until mytask done;

var manualresetevent = new manualresetevent(false);  task.run(() => mytask()).continuewith(x => { manualresetevent.set(); });  manualresetevent.waitone(); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -