Avoiding Implicid Conversion?

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
 
M

Mattias Sjögren

process_UDP_Message(RecieveBuffer)

process_UDP_Message(CType(RecieveBuffer, Byte()))


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top