change from backgroundworker to async/await
I want to change backgroundworker with async/await. In my current scenario i had a backgroundworker declared in the controller. it has two method dowork and RunWorkerCompleted there. So my UI has call controller function that call backgroundworker.RunWorkerAsync().. how i change all this to async/await ? But those async/await stays in the controller.
6 Replies
i don't really know if there is a one-size-fits-all solution
@TcoUpLoad you say "controller", is this asp.net?
in any, the general replacement for BackgruondWorker is Task.Run https://blog.stephencleary.com/2013/05/taskrun-vs-backgroundworker-intro.html
Task.Run vs BackgroundWorker: Intro
This is an introductory post for a new series that I’ll be doing comparing BackgroundWorker to Task.Run (in an async style). I always recommend Task.Run, and I have already written a long post describing why, but I still see some developers resisting the New Way of Doing Things (TM). So this will be a short series where I’ll compare the code sid...
but if this is a web server, you may not want either of those, hence my question
No. Windowsforms
Ah ok.
Then yeah, Task.Run all the way.