RSS

Create New Thread in C#

Wed, Dec 2, 2009

Programming, Tutorials

Following exampel demonstrates how can we create a new thread using C#.

i. Create aThreadStart delegate.
ii. Create instance of Thread by passing this delegate as a parameter.
iii.Call the Thread.Start method (i.e. WorkerFunction).

using System.Threading;
Thread newThread = new Thread(new ThreadStart(WorkerFunction));
newThread.Start();

The WorkerFunction could be defined as follows.

public void WorkerFunction()
{
  try
  {
    // work
  }
  catch (Exception ex)
  {
    // catch exception
  }
}
Sharing ~ Helping Other:
  • Print
  • email
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • BlinkList
  • DZone
  • Slashdot
  • YahooMyWeb
  • StumbleUpon
  • Live
  • IndianPad
  • DotNetKicks
  • Technorati

Related Posts:

, ,

This post was written by:

eXclusiveMinds - who has written 500 posts on eXclusiveMinds.


Contact the author

4 Comments For This Post

  1. digeOveva Says:

    Hello

    Thanks for this page, very interesting info.

  2. mekmeebra Says:

    Greetings…

    I just had the urge to wish yous all happy holidays.

    Laters Ya’ll!!!

    ~ Tabea Russel ~
    http://www.bible-knowledge.com/10-Commandments.html

  3. Gliluviagnign Says:

    Nice one

  4. atmoveThattep Says:

    Hello

    Thank’s for this page, very useful info.


    callaway curtain escaflowne , advanced sweater leaf , chef mirror usb , advanced rack braided , north drive tire

Leave a Reply

You must be logged in to post a comment.