Jump to content
Xtreme .Net Talk

Try to learn Multi-thread......


Recommended Posts

Posted

Hi,

 

Can you show me a very very simple example using Multi-thread?

 

Thank you in advance.

  • *Gurus*
Posted

Straight from the .NET SDK:

 

Imports System
Imports System.Threading

Public Class ThreadWork
  
  Public Shared Sub DoWork()
     Dim i As Integer
     For i = 0 To 2
        Console.WriteLine("Working thread...")
        Thread.Sleep(100)
     Next i
  End Sub 'DoWork
End Class 'ThreadWork

Class ThreadTest
  
  Public Shared Sub Main()
     Dim myThreadDelegate As New ThreadStart(AddressOf ThreadWork.DoWork)
     Dim myThread As New Thread(myThreadDelegate)
     myThread.Start()
     Dim i As Integer
     For i = 0 To 2
        Console.WriteLine("In main.")
        Thread.Sleep(100)
     Next i
  End Sub 'Main
End Class 'ThreadTest

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...