From: Dan on 5 Mar 2010 08:09 Hi, Hopefully i can make myself clear :-) If I have an array if objects and I loop through the array and call a method of each object in a different thread, can I use the same handler when the thread completes or will this cause problems? Something like: Private ProcessResultHandler As AsyncCallback = AddressOf ProcessResults For i = 0 To ComputerArray.GetUpperBound(0) sfh = AddressOf ComputerArray(i).UninstallAgent sfh.BeginInvoke(ProcessResultHandler, Nothing) Next i Public Sub ProcessResults() DoSomething() End Sub Thanks! Dan
From: Herfried K. Wagner [MVP] on 5 Mar 2010 20:44 Am 05.03.2010 14:09, schrieb Dan: > If I have an array if objects and I loop through the array and call a method > of each object in a > different thread, can I use the same handler when the thread completes or > will this cause problems? > > Something like: > > Private ProcessResultHandler As AsyncCallback = AddressOf ProcessResults > > > For i = 0 To ComputerArray.GetUpperBound(0) > sfh = AddressOf ComputerArray(i).UninstallAgent > sfh.BeginInvoke(ProcessResultHandler, Nothing) > Next i > > Public Sub ProcessResults() > DoSomething() > End Sub This should work. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
From: Dan on 8 Mar 2010 07:29 Thanks! Dan "Herfried K. Wagner [MVP]" <hirf-spam-me-here(a)gmx.at> wrote in message news:Oh7%23V6MvKHA.5036(a)TK2MSFTNGP02.phx.gbl... > Am 05.03.2010 14:09, schrieb Dan: >> If I have an array if objects and I loop through the array and call a >> method >> of each object in a >> different thread, can I use the same handler when the thread completes or >> will this cause problems? >> >> Something like: >> >> Private ProcessResultHandler As AsyncCallback = AddressOf ProcessResults >> >> >> For i = 0 To ComputerArray.GetUpperBound(0) >> sfh = AddressOf ComputerArray(i).UninstallAgent >> sfh.BeginInvoke(ProcessResultHandler, Nothing) >> Next i >> >> Public Sub ProcessResults() >> DoSomething() >> End Sub > > This should work. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
|
Pages: 1 Prev: write to a new file at new user defined directory Next: Border style of panel. |