start new thread help

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

    #1

    start new thread help

    Tooo many examples. I'm confused.

    VB6 ActiveX.dll with no windows or controls. Interfaces with a device that
    returns an x size byte array every x milliseconds for x counts. Sends a
    message to VB2005 main thread on each count.

    VB2005 has to start the thread and set several variables in the thread
    before loop starts.

    VB2005 then has to respond to messages and draw on screen until last count
    is recieved.

    VB2005 then stops thread. Thread will be started and stopped numerous times.

    It's the starting and stopping the dll thread that has me befuddled.

    Code anyone? A link to proper help?

    Galen


  • Luke Zhang [MSFT]

    #2
    RE: start new thread help

    Hello Galen,

    I think we may first make the question clear, so that we can just be on the
    right track :)

    As I understand, you have a VB .NET 2005 winform project and it calls a VB
    6.0 ActiveX DLL component. The DLL component will communicate with a device
    to gather data, then send messages to the winform application. In the
    Winform application, you need to start a thread to handle these
    message/data and display on the form.

    But I still have some unclear:

    1. How did you send message from ActiveX DLL to winform application?
    2. What is the actual issue, start a .NET thread or communicate with the
    ActiveX DLL?

    Regards,

    Luke Zhang
    Microsoft Online Community Lead

    =============== =============== =============== =====
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    =============== =============== =============== =====

    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Comment

    • Galen Somerville

      #3
      Re: start new thread help

      1. How did you send message from ActiveX DLL to winform application?

      In dll compiled with "Unattended execution" and "Retained in Memory"
      Const WM_COPYDATA = &H4A
      Private Type COPYDATASTRUCT
      dwData As Long
      cbData As Long
      lpData As Long
      End Type
      Private Declare Function SendMessage Lib "user32" Alias "SendMessag eA" _
      (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
      Any) As Long

      Public Property Let WinHandle(ByVal value As Long)
      gHwnd = value
      End Property

      Public Sub SendData(ByVal hWnd As Long, ByRef data() As Byte)
      Dim cds As COPYDATASTRUCT
      cds.cbData = UBound(data) - LBound(data) + 1
      cds.lpData = VarPtr(data(0))
      SendMessage ByVal hWnd, WM_COPYDATA, ByVal hWnd, cds
      End Sub

      And finally in Loop
      SendData gHwnd, DatAry
      2. What is the actual issue, start a .NET thread or communicate with the
      ActiveX DLL?
      Yes. How do I start the separate thread and send it some data before the
      data gathering loop starts.

      Galen

      "Luke Zhang [MSFT]" <lukezhan@onlin e.microsoft.com wrote in message
      news:Nk4bGSApGH A.4612@TK2MSFTN GXA01.phx.gbl.. .
      Hello Galen,
      >
      I think we may first make the question clear, so that we can just be on
      the
      right track :)
      >
      As I understand, you have a VB .NET 2005 winform project and it calls a VB
      6.0 ActiveX DLL component. The DLL component will communicate with a
      device
      to gather data, then send messages to the winform application. In the
      Winform application, you need to start a thread to handle these
      message/data and display on the form.
      >
      But I still have some unclear:
      >
      1. How did you send message from ActiveX DLL to winform application?
      2. What is the actual issue, start a .NET thread or communicate with the
      ActiveX DLL?
      >
      Regards,
      >
      Luke Zhang
      Microsoft Online Community Lead
      >
      =============== =============== =============== =====
      When responding to posts, please "Reply to Group" via your newsreader so
      that others may learn and benefit from your issue.
      =============== =============== =============== =====
      >
      (This posting is provided "AS IS", with no warranties, and confers no
      rights.)
      >

      Comment

      • Luke Zhang [MSFT]

        #4
        Re: start new thread help

        Hello Galen,

        Did you want to start the thread from winform application, or the ActiveX
        DLL? If it is winform application, you may consider the Thread class in
        .NET or BackgroundWorke r Class ( new in .NET framework 2.0):

        http://msdn2.microsoft.com/en-us/lib....backgroundwor
        ker.aspx

        If you want pass some data into a thread, you may use some public variant
        which can be accessed in a thread.

        Regards,

        Luke Zhang
        Microsoft Online Community Lead

        =============== =============== =============== =====
        When responding to posts, please "Reply to Group" via your newsreader so
        that others may learn and benefit from your issue.
        =============== =============== =============== =====

        (This posting is provided "AS IS", with no warranties, and confers no
        rights.)

        Comment

        • Galen Somerville

          #5
          Re: start new thread help

          The thread will start from the winform application. I will look at the
          BachgroundWorke r class.

          Your coworker Walter Wang is looking at other aspects of my problem.

          Galen

          "Luke Zhang [MSFT]" <lukezhan@onlin e.microsoft.com wrote in message
          news:KhBzSzKpGH A.4612@TK2MSFTN GXA01.phx.gbl.. .
          Hello Galen,
          >
          Did you want to start the thread from winform application, or the ActiveX
          DLL? If it is winform application, you may consider the Thread class in
          NET or BackgroundWorke r Class ( new in .NET framework 2.0):
          >
          http://msdn2.microsoft.com/en-us/lib....backgroundwor
          ker.aspx
          >
          If you want pass some data into a thread, you may use some public variant
          which can be accessed in a thread.
          >
          Regards,
          >
          Luke Zhang
          Microsoft Online Community Lead
          >
          =============== =============== =============== =====
          When responding to posts, please "Reply to Group" via your newsreader so
          that others may learn and benefit from your issue.
          =============== =============== =============== =====
          >
          (This posting is provided "AS IS", with no warranties, and confers no
          rights.)
          >

          Comment

          • Luke Zhang [MSFT]

            #6
            Re: start new thread help

            Hi Galen,

            Thank you for the information. I will talk to Walter on the backgroud
            informaiton of this issue. If you have any questions, please feel free to
            post here , or another with Walter.

            Regards,

            Luke Zhang
            Microsoft Online Community Lead

            =============== =============== =============== =====
            When responding to posts, please "Reply to Group" via your newsreader so
            that others may learn and benefit from your issue.
            =============== =============== =============== =====

            (This posting is provided "AS IS", with no warranties, and confers no
            rights.)

            Comment

            Working...