Great, great, great!!
You're great! Thank you, using ThreadPool my application works well, and I
can manager the operation as I need.
thank you a lot!
If this can be usefult to other people, I defined a custom event, and a kind
of wrapper that may execute all subscribed eventhandlers in async way:
Public Custom Event DataReceived As EventHandler(Of DataReceivedEventArgs)
[...]
RaiseEvent(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
For Each item As EventHandler(Of DataReceivedEventArgs) In
_dataReceivedHanlders
Dim p As New Threading.WaitCallback(AddressOf prova)
System.Threading.ThreadPool.QueueUserWorkItem(p, New Object() {item, Me, e})
Next
End RaiseEvent
End Event
Private Sub prova(ByVal state As Object)
Dim a As Object() = DirectCast(state, Object())
Dim eventHandler As EventHandler(Of DataReceivedEventArgs) =
DirectCast(a(0), EventHandler(Of DataReceivedEventArgs))
Dim sender As Object = a(1)
Dim e As DataReceivedEventArgs = DirectCast(a(2), DataReceivedEventArgs)
eventHandler.Invoke(sender, e)
End Sub