C
C#4mo ago
TcoUpLoad

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
Omnissiah
Omnissiah4mo ago
i don't really know if there is a one-size-fits-all solution
jcotton42
jcotton424mo ago
@TcoUpLoad you say "controller", is this asp.net?
jcotton42
jcotton424mo ago
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...
jcotton42
jcotton424mo ago
but if this is a web server, you may not want either of those, hence my question
TcoUpLoad
TcoUpLoadOP4mo ago
No. Windowsforms
jcotton42
jcotton424mo ago
Ah ok. Then yeah, Task.Run all the way.
Want results from more Discord servers?
Add your server