threading

  • Thread starter Thread starter Guest
  • Start date Start date
This is a modified example from MSDN available at
http://msdn.microsoft.com/library/d...frlrfSystemThreadingThreadClassStartTopic.asp

Imports System

Imports System.Threading

Public Class ThreadWork

Public Shared nCount As Integer = 0

Public Shared Sub DoWork()

Dim nThreadNo As Integer

nCount = nCount + 1

nThreadNo = nCount

Console.WriteLine("Thread Starting " & nThreadNo)

Thread.Sleep(nThreadNo * 50)

Console.WriteLine("Thread Exiting " & nThreadNo)

End Sub 'DoWork

End Class 'ThreadWork

Class ThreadTest

Public Shared Sub Main()

Dim myThreadDelegate As New ThreadStart(AddressOf ThreadWork.DoWork)

Dim myThread As Thread

Dim i As Integer

For i = 1 To 8

myThread = New Thread(myThreadDelegate)

myThread.Start()

Next

Thread.Sleep(1000)

End Sub 'Main

End Class 'ThreadTest

HTH
rawCoder
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

multi threading 13
A lot of spammers recently 13
Doom on a tractor 0
Can I get a "welcome back"? 20
Window Maker a very fine window manager. 32
basic threading question 2
Multi-Threaded App 5
threading questions 6

Back
Top