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

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -