c# - How do run await in background in window phone? -
i want run method on background when app closed.
async private void() { var bgw = new backgroundworker(); bgw.dowork += (s,v) => { string temp= await dosomething(); }; bgw.runworkercompleted += (s,v) => { //... }; bgw.runworkerasync(); } it produces following error
the await operator can used within async lambda expression.
how fix it?
dowork cannot async. recommend use task.run instead:
async private void x() { await task.run(() => dosomething()); //... } however, may need call wait instead of await since done @ application shutdown.
Comments
Post a Comment