Winforms application hungs when switching to another app

Posted by joseluisrod on Stack Overflow See other posts from Stack Overflow or by joseluisrod
Published on 2010-03-12T16:45:55Z Indexed on 2010/03/12 16:47 UTC
Read the original article Hit count: 453

Hi, I believe I have a potential threading issue. I have a user control that contains the following code:

private void btnVerify_Click(object sender, EventArgs e)
{
    if (!backgroundWorkerVerify.IsBusy)
    {
        backgroundWorkerVerify.RunWorkerAsync();
    }
}

private void backgroundWorkerVerify_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { VerifyAppointments(); }

private void backgroundWorkerVerify_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) {

    MessageBox.Show("Information was Verified.", "Verify",
        MessageBoxButtons.OK, MessageBoxIcon.Information);
    CloseEvent();
}

vanilla code. but the issue I have is that when the application is running and the users tabs to another application when they return to mine the application is hung, they get a blank screen and they have to kill it. This started when I put the threading code. Could I have some rogue threads out there? what is the best way to zero in a threading problem? The issue can't be recreated on my machine...I know I must be missing something on how to dispose of a backgroundworker properly. Any thoughts are appreciated, Thanks,

Jose

© Stack Overflow or respective owner

Related posts about multithreading

Related posts about backgroundworker