question Threading. 
Author Message
 question Threading.

could any one explain what is the difference between these two samples of
code.

1***************************************
         Private WithEvents thr1 As New mythr()
      Private WithEvents thr2 As New mythr()

Private Sub frm_Load(ByVal sender As System.Object, ByVal e As    
System.EventArgs) Handles MyBase.Load

Dim thrStart1 As New ThreadStart(AddressOf AddressOf thr1.myFunction)
Dim thread1 As New Thread(thrStart1)

Dim thrStart2 As New ThreadStart(AddressOf AddressOf thr2.myFunction)
Dim thread2 As New Thread(thrStart2)
                thread1.start()
                thread2.start()
end sub

Private Sub mythr_threadEnd(ByVal message As String) Handles
thr1.threadEnd,thr2.threadEnd
        msgbox(message)
ned sub
**************************************

2***********************************************

    Private Sub frm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        dim thr1 As New mythr()
     dim thr2 As New mythr()

  Dim thrStart1 As New ThreadStart(AddressOf AddressOf thr1.myFunction)
  Dim thread1 As New Thread(thrStart1)

  Dim thrStart2 As New ThreadStart(AddressOf AddressOf thr2.myFunction)
  Dim thread2 As New Thread(thrStart2)

           AddHandler thr1.threadEnd, AddressOf onThreadend
        AddHandler thr2.threadEnd, AddressOf onThreadend
                thread1.start()
                thread2.start()
end sub

Private Sub onThreadend(ByVal message As String)
        msgbox(message)
end sub
********************************************************



Sat, 29 Jan 2005 21:01:05 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Safe threading by delivering EVENTS to UI THREAD

2. Threading problem --> threads die

3. Thread error without threads

4. threading - Multiple threads returning values at same time

5. Opening a form in a new thread, appart from the Apps main thread

6. Will child-thread end when main thread end?

7. thread spawning a thread?

8. single thread and apartment threads

9. Single Thread and Apartment Thread Problem

10. Single Threaded instead of Apartment Threaded ???

11. Apartment thread or Single thread?

12. CreateObject, Thread per Object, and the Main Thread

 

 
Powered by phpBB® Forum Software