From: Dan on
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
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
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/>