Results 1 to 3 of 3

Thread: Multithreading

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Egypt
    Posts
    179
    How to do Multithread programming using Visual Basic ?

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Code:
    'In a form
    'Add a command button to the form
    Private Sub Command1_Click()
    'After you click this button, try to move the window
        'You will see that the AsyncThread-function was executed asynchronously
        Dim hThread As Long, hThreadID As Long
        hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf AsyncThread, ByVal 0&, ByVal 0&, hThreadID)
        CloseHandle hThread
    End Sub
    'In a module
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
    Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Public Sub AsyncThread()
        'Let this thread sleep for 10 seconds
        Sleep 10000
    End Sub
    But note thet this is not as good as it can be done in C++. Also this is a very complex area of windows programming.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Member
    Join Date
    Mar 2001
    Posts
    56

    Cool True multithread VB source code controls


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width