.NET Diary

March 19, 2013

BackgroundWorker : The basics

Filed under: All, C# — leoullas @ 2:29 pm

1. Add in your Windows form:

Tools -> backgroundWorker1

2. Event: Introduce the activities in the event “backgroundWorker1_DoWork”

In my Start Process GUI button click, I am calling the followings to start the back process.

blStopBackTrackProcess = false;
backgroundWorker1.RunWorkerAsync();

Then, I have written a non-stop continuous process which is breaking on a boolean value change on my Stop Process GUI button click event.

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{

while (1==1){

Thread.Sleep(DRLib.ClConstants.Check_Interval_Second * 1000);
MessageBox.Show(“abcd” );
CheckNormalServers();

if (blStopBackTrackProcess == true)
break;
}
}

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: