Search code examples
vb.netmultithreadingbackgroundworkerprocedures

Sequential procedures inside DoWork BackgroundWorker


I'm looking to run sequential sub procedures in a background thread. and am wondering if it is permissible to do such by creating a background worker and then calling each procedure separately like so...

Private Sub BGW_DoWork(ByVal sender As System.Object, ByVal e As DoWorkEventArgs) 
_Handles BGW.DoWork

Procedure1()
Procedure2()
Procedure3()

End Sub

Will this run each procedure in the background thread?

Also, reading other posts some suggested to use a List<svnCommand> and pass them to RunWorkerAsync in C#, while others suggested using Tasksmethod, both of which I have no knowledge of. Will any of these two work and what are they?


Solution

  • No, it is not necessary to put each subroutine in its own BackgroundWorker. I regularly call multiple subroutines from my DoWork handler. Any subroutines called from that handler will execute in the background thread.