View Single Post
  #4 (permalink)  
Old 02-17-2009, 3:13 PM
DanielFL DanielFL is offline
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Feb 2009
Posts: 5
Reputation: 0
DanielFL is on a distinguished programming path ahead
Lightbulb I almost work...

that article was very interestign and I made significiant progress.
I am, hovere stuck at the end.
I made my download working with System.ComponentModel.BackgroundWorker, however because I know in the future I want to have more workers, while firing RunWorkerAsync(param) I am passing an Array Object in param. this way I can have different tasks run through a worker.
So when I do _DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) i can switch through e.Argument(0) and look which task to do... then all necessary variables I can pass through that object like lets say Dim Filename As String = e.Argument(1), Dim sURL As String = e.Argument(2)

There is not a problem with checking state for different thread through _ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) because again I can do switch around e.UserState(0) (that matches e.Argument(0) ), however when it comes to the final step -- _RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles TestWorker.RunWorkerCompleted - the e.Argument(0) is not there, neither is e.UserState(0).

Question: how can I distinquish which action is completed if I want to use Worker for more than one task i presented here model where passed Variable is an Array?

thank you for your helpful help!
Reply With Quote