Forum Moderators: open

Message Too Old, No Replies

Start multiple threads in VB.Net

         

ntqb

1:10 pm on Oct 5, 2008 (gmt 0)

10+ Year Member



Hi!

Can someone show me how to start multiple threads in vb.net ?

Thanks!

mrMister

3:21 pm on Oct 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




Dim myThread As Thread = New Thread(New ThreadStart(mythreadmethod))
myThread.Start()

Private Sub mythreadmethod()
' Code you put here will be run in a new thread.
End Sub

ntqb

7:17 am on Oct 11, 2008 (gmt 0)

10+ Year Member



Thanks!

If i run 5 threads then i must write this code 5 times or just put the code once ?

mrMister

2:01 pm on Oct 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




Dim myThread1 As Thread = New Thread(New ThreadStart(mythreadmethod1))
myThread1.Start()

Dim myThread2 As Thread = New Thread(New ThreadStart(mythreadmethod2))
myThread2.Start()

Private Sub mythreadmethod1()
' Code you put here will be run in a new thread.
End Sub

Private Sub mythreadmethod2()
' Code you put here will be run in a new thread.
End Sub