Why does setting a form's enabled property crash the application?
Posted
by Ruirize
on Stack Overflow
See other posts from Stack Overflow
or by Ruirize
Published on 2010-06-02T20:05:40Z
Indexed on
2010/06/02
20:24 UTC
Read the original article
Hit count: 239
private void launchbutton_Click(object sender, EventArgs e)
{
launchbutton.Enabled = false;
Process proc = new Process();
proc.EnableRaisingEvents = true;
proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
//The arguments/filename is set here, just removed for privacy.
proc.Exited += new EventHandler(procExit);
proc.Start();
}
private void procExit(object sender, EventArgs e)
{
MessageBox.Show("YAY","WOOT");
Thread.Sleep(2000);
launchbutton.Enabled = true;
}
2 Seconds after I quit the created process, my program crashes. Why?
© Stack Overflow or respective owner