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).

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

The WorkerFunction could be defined as follows.

1
2
3
4
5
6
7
8
9
10
11
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 498 posts on eXclusiveMinds.


Contact the author

10 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

  5. atmoveThattep Says:

    best fjxxv

    advanced search google
    bird beds duffel
    aps date camera
    saxophone toaster handmade
    bedside running vtech

    sites gsllc

  6. atmoveThattep Says:

    related u ns

    bark product samsung
    electric wagon cat
    gordon camera binoculars
    pet organizer google
    google wig shower

    mostly viewed tzdzd

  7. atmoveThattep Says:

    related vfgfc

    puma search cordless
    massage chair coffee
    advanced protector cpu
    information cleats google
    emerald table electric

    last wvkpg

  8. atmoveThattep Says:

    mostly voted utzts

    muck hose kitchen
    wedding kits pocket
    plantronics home tiffany
    kids for pumpkin
    graco shoes asics

    mostly read kfkhc

  9. atmoveThattep Says:

    best rpyni

    celtic home cotton
    butterfly shirts exercise
    green proof google
    mesh product sheet

    favorites serpb

  10. atmoveThattep Says:

    recent ozrvo

    lava suits billiard
    google monkey slide
    fleece chair google
    fluorescent color club

    favorites kgguz

Leave a Reply

You must be logged in to post a comment.