Thread Example

Posted on 2006-11-25
Last Modified: 2010-04-16

How to use thread in the C#,

Can someone give me small example on threads

Kind Regards,
Question by:dinesh_bali
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
LVL 29

Expert Comment

ID: 18011008
LVL 20

Expert Comment

ID: 18011260
public System.Threading.Thread Thread1 = new Thread(new ThreadStart(AlertIt_One));
public System.Threading.Thread Thread2 = new Thread(new ThreadStart(AlertIt_Two));

public void Button1_Click(object sender, EventArgs e)

public void AlertIt_One()
MessageBox("Fired 1");

public void AlertIt_Two()
MessageBox("Fired 2");

Author Comment

ID: 18011283
Hi Thanks for the example.

Can we commumicate between two threads

say thread 1 and thread 2, when the process of the thread 1 completes

Kind Regards
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

LVL 29

Expert Comment

ID: 18011316
Yes - you can raise events between the threads.

Or you can simply have a timer in the main thread checking the state of the thread:
if (
Thread1.ThreadState == ThreadState.Unstarted ||
Thread1.ThreadState == ThreadState.Stopped ||
Thread1.ThreadState == ThreadState.Aborted ||
Thread1.ThreadState == ThreadState.Suspended )
  This thread is dead.

Have a look at for some more examples
LVL 29

Expert Comment

ID: 18011399
Sorry, I am working in too many languages at the same time - they are all starting to merge into one ;). That was a VB.NET example

have a look at 'Using events for thread synchronization'
LVL 29

Accepted Solution

Nightman earned 500 total points
ID: 18011411
Another example:

Both this one and my previous post have downloadable, working code samples
LVL 29

Expert Comment

ID: 18198051
Hi dinesh_bali

Did our comments assist you? If not, please can you provide some feedback so that we can assist you further. Alternatively, have a look at for information on closing questions.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unlocking a column in excel using C# 17 33
parse string in c# 5 41
ComboBox to String Not Working 5 43
XML Constructor Throwing Incorrectly Structured Document Error 4 23
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question