Results 1 to 4 of 4

Thread: Multithreading

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Multithreading

    I just purchased a book that seems to
    talk more about synchronization issues
    than thread creation so im still a little
    confused about how to create a thread
    in Visual Basic.

    In Java all i would have to do is create a class
    that implements the Runnable interface
    and override the run() method.
    Then create an instance of that class
    within the threads constructor and call
    start on the thread which in turn would call
    run() on the target threads code.

    Visual Basic seems to take a slightly diffrent
    approach to thread creation using ThreadStart
    to get a address pointer to the code which
    will run as a seperate process then pass that
    to a Thread object.

    Code:
    Imports System.Threading
    
    Dim _thread as Thread 
    Dim threadStart as ThreadStart
    
    threadStart  = New ThreadStart(AddressOf Me.Start)
    
    _thread = New Thread(threadStart)
    _thread.Start()
    Is this the only way to create a seperate
    process of execution? Has anyone else
    tried multithreading yet? Any suggestions
    or comments would be helpful.

  2. #2
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    VB Code:
    1. Sub BeBusy()
    2.  
    3.   Dim i As Decimal
    4.  
    5.   For i =1 To 10000000
    6.     ‘do nothing but tie up app
    7.   Next
    8.  
    9.   Beep()
    10.  
    11. End Sub
    12.  
    13.  
    14. Private Sub button4_Click(ByVal sender As System.Object,_
    15. ByVal e As System.EventArgs)Handles button4.Click
    16.  
    17.   Dim busyThread As New System.Threading.Thread(AddressOf BeBusy)
    18.  
    19.   busyThread.Start()
    20.  
    21. End Sub

    ??
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  3. #3

  4. #4
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796

    Thumbs up

    .
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

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