Avoiding Implicid Conversion?

  • Thread starter Thread starter gregory_may
  • Start date Start date
G

gregory_may

I am using a threadpool to process UDP broadcast messages. I cant figure
out how to type the threadpool call back. Below is a snip of my code. The
"process_UDP_Message" needs to pass a byte array .... but the Call Back
only passes back a generic object. Anyone know how I can force the type of
"receiveBuffer" when I make the call to process_UDP_Message?


'Main processing loop:
If Not ThreadPool.QueueUserWorkItem _
(New WaitCallback(AddressOf process_UDP_Message_deligate),
ExactBufferSize) Then
Debug.WriteLine("Could not queue to thread pool.")
End If


Private Sub process_UDP_Message_deligate(ByVal RecieveBuffer As Object)
'We are "late binding" & converting the object back to a byte array.
Not sure
'What the performance of this is?
process_UDP_Message(RecieveBuffer)
End Sub


Private Sub process_UDP_Message(ByVal RecieveBuffer() As Byte)
'Process Message
 
process_UDP_Message(RecieveBuffer)

process_UDP_Message(CType(RecieveBuffer, Byte()))


Mattias
 
Back
Top