Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 426

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/templates/ja_purity/ja_templatetools.php on line 49
Writing a Multi-threaded Application Using VB.NET - The Scripts Library Community

Free Programming Tutorials & Source Code

 
  • Increase font size
  • Default font size
  • Decrease font size
Home Visual Basic.NET Writing a Multi-threaded Application Using VB.NET

Writing a Multi-threaded Application Using VB.NET

(0 votes, average: 0 out of 5)

Developing a multi-threading application in VB.NET is simple. This tutorial is directed to beginners who want to get involved into the multithreading application development. First, let's define the threading namespace:
 
Imports System.Threading

Using the Thread class of the System.Threading namespace to create, pause, delete, of resume a thread. Let create a thread:
 
Private MyThread as Thread = New Thread(New ThredStart(TestThread))

Use the "Start" method to start the thread:
  
MyThread.Start()


TestThread is a Sub executed by all thread
 
Sub TestThread()

Dim strThread as String

Dim i as integer

For i =0 To 1000

strThread="Thread Number: " & i.ToString()

Comsole.WriteLine(strThread)

Next

End Sub

In order to aboard a running thread, use the Abort method. Before you use it, make sure the thread is alive:
 
If MyThread.IsAlive Then

MyThread.Abort()

End If

A Sleep method using to pause a thread:
 
MyThread.Sleep()

To set up a thread priority, use the Priority method from the Thread class. ThreadPriproty property is used to set a thread pripority.Values of this property are: Normal, AboveNorma, BelowNormal, Highest, and Lowest. Here is an example of setting up a therad priority:
 
Private MyThread.Priority = ThreadPriority.Lowest

The Suspend method is used to suspend a thread. The thread remains suspended until Resume method is called. Suspend and Resume are methods of the Thread Class. Here is an example to suspend a thread:

If MyThread.ThreadState = ThreadState.Running Then

MyThread.Suspend()

End If

And to resume a thread:
  
If MyThread.ThreadState = ThreadState.Suspended Then

MyThread.Resume()

End If

That's it!!