Syntax for setting thread priority in VB.NET

Status
Not open for further replies.
I think it will be easiest to show in an example. Here's some (slightly modified for the example) code from a C# project I'm working on. The VB.NET code will be virtually identical, save for differences in language syntax.

Code:
// Create the ThreadStart object to begin the thread
Thr.ThreadStart startThread = new Thr.ThreadStart(StartMethod);			
// Create a new thread using the ThreadStart object
Thr.Thread thread = new Thr.Thread(startThread);

// Set the name
thread.Name = "ThreadName";

// Set the background thread value
// This will usually be false unless you understand the implications
thread.IsBackground = IsBackground;

// Set the priority of the thread, this value was passed in
// as a parameter in this example. 
thread.Priority = Priority;

thread.Start();

Thr is an alias to System.Threading. Use System.Threading where you see Thr.

StartThread is the method to run in the new thread, taking no arguments and having a void return value. Use a "Sub" in VB.

Priority is one of the System.Threading.ThreadPriority constants.

Edit: Where'd my linebreaks in the code block go?
 
Status
Not open for further replies.