Ok, I figured out another problem. I actually want to pass 2 parms to the
process_Inbound_Message_deligate. I could create a structure for this, but
I need the objects ByRef not ByVal. (How do you create a structure with
ByRef items?
Is this possible?
This is sort of what I want? But, I have not idea how to get a Pointer to
a Class or a pointer to a String array. Maybe there is another way to pass
in multiple parms to a ThreadPool? Help. I am being sucked into a black
hole of pointers.
'Do I need a structure to get multiple objects into a threadpool object?
Public Structure ThreadPoolPayload
Public StringArray_Ptr As IntPtr
'Should be a Pointer to a very large String array (not a copy)
Public Client_ptr As IntPtr
'Should be a Pointer to a class instance (not a copy).
End Structure
Main Routine.
.
Dim dataArray() As String
If Not ThreadPool.QueueUserWorkItem _
Dim MyThreadPoolPayload As New ThreadPoolPayload
MyThreadPoolPayload.StringArray_Ptr =
GetPointerToThisObject(dataArray)
MyThreadPoolPayload.Client_Ptr = GetPointerToThisObject(sender)
(New WaitCallback(AddressOf process_Inbound_Message_deligate),
MyThreadPoolPayload) Then
Debug.WriteLine("Could not queue to thread pool.")
End If
.
End of Main Routine.
Private Sub process_Inbound_Message_deligate(ByVal Payload As Object)
'We are "late binding" & converting the object back to a byte array.
Not sure
'What the performance of this is?
process_Inbound_Message(Payload)
End Sub
Private Sub process_Inbound_Message(ByVal MyThreadPoolPayload As
threadPoolPayload)
'Do work here with MyClient and MyStringArray
End Sub
[quoted text, click to view] "gregory_may" <None> wrote in message
news:uH4d4eGRFHA.3156@TK2MSFTNGP15.phx.gbl...
>I am using the thread pool.
>
> I would like to prevent late binding, but cant figure out how. When the
> WaitCallback function is called, it expects a function prototype with type
> OBJECT. My rotuine that does the real work, needs it as a string Array.
> Whats the best peformance way to handle this?
>
> Thanks!
>
>
> Main Routine.
>
> .
>
>
>
> Dim dataArray() As String
>
>
>
> If Not ThreadPool.QueueUserWorkItem _
>
> (New WaitCallback(AddressOf process_Inbound_Message_deligate),
> dataArray) Then
>
> Debug.WriteLine("Could not queue to thread pool.")
>
> End If
>
>
>
> .
>
> End of Main Routine.
>
>
>
> Private Sub process_Inbound_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_Inbound_Message(RecieveBuffer)
>
> End Sub
>
>
>
> Private Sub process_Inbound_Message(ByVal DataArray() As String)
>
> 'Do work here with DataArray()
>
>
>
>
>
> End Sub
>
>