Half_Baked
Half_Baked

Reputation: 340

Show (popup) Dialog Form using Background Worker?

I must sleep my main thred 5 times, pausing 10 seconds each time for a certain task. Problem is that my main windows form freezes during the duration. So, I'd like to show a pop-up window wich is not frozen.

I've added a background worker to my main form:

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
// ... how do I involve this?
}

When I push a button on my main form it does this:

BussyWindow bussyWindow = new BussyWindow();
bussyWindow.ShowDialog();

And then my main form goes into a loop for about 50 seconds.

I've tried:

BackgroundWorker bw = new BackgroundWorker();
bw.RunWorkerAsync(bussyWindow);

I'm stuck! What to try next?

Upvotes: 1

Views: 1058

Answers (1)

Selman Genç
Selman Genç

Reputation: 101681

You don't need another form if you are using BackgroundWorker,try this:

 BackgroundWorker bw = new BackgroundWorker();
        bw.DoWork += bw_DoWork;
        bw.RunWorkerAsync();

private void bw_DoWork(object sender, DoWorkEventArgs e)
    {
        // do your work here
    }

Your work will be done asynchronously..

Upvotes: 1

Related Questions