Avoiding Implicid Conversion?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gregory_may

    #1

    Avoiding Implicid Conversion?

    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_Me ssage" 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
    "receiveBuf fer" when I make the call to process_UDP_Mes sage?


    'Main processing loop:
    If Not ThreadPool.Queu eUserWorkItem _
    (New WaitCallback(Ad dressOf process_UDP_Mes sage_deligate),
    ExactBufferSize ) Then
    Debug.WriteLine ("Could not queue to thread pool.")
    End If


    Private Sub process_UDP_Mes sage_deligate(B yVal 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_Mes sage(RecieveBuf fer)
    End Sub


    Private Sub process_UDP_Mes sage(ByVal RecieveBuffer() As Byte)
    'Process Message


  • Mattias Sjögren

    #2
    Re: Avoiding Implicid Conversion?

    > process_UDP_Mes sage(RecieveBuf fer)

    process_UDP_Mes sage(CType(Reci eveBuffer, Byte()))


    Mattias

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    • gregory_may

      #3
      Re: Avoiding Implicid Conversion?

      thanks!

      "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rg> wrote in message
      news:urPvyL0MGH A.2704@TK2MSFTN GP15.phx.gbl...[color=blue][color=green]
      >> process_UDP_Mes sage(RecieveBuf fer)[/color]
      >
      > process_UDP_Mes sage(CType(Reci eveBuffer, Byte()))
      >
      >
      > Mattias
      >
      > --
      > Mattias Sjögren [C# MVP] mattias @ mvps.org
      > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      > Please reply only to the newsgroup.[/color]


      Comment

      Working...