| Author |
Application.Exit() not working
|
|
| lbolognini@gmail.com 2006-06-24, 8:15 am |
| Hi all,
got this code inside a Windows Form 1.1 that opens a file with Notepad:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = true;
proc.StartInfo.FileName = "Notepad";
proc.StartInfo.Arguments =
" C:\\WINDOWS\\system32\\drivers\\etc\\hos
ts";
proc.Start();
if (proc.HasExited == true)
{
//why doesn't this work?
Application.Exit();
}
Why isn't the application exiting when I close Notepad? How do i make
it behave like that?
Thanks,
Lorenzo
| |
| Josh Twist 2006-06-28, 8:03 am |
| private void Foo()
{
Process proc = new Process();
proc.StartInfo.FileName = "Notepad";
proc.StartInfo.Arguments =
" C:\\WINDOWS\\system32\\drivers\\etc\\hos
ts";
proc.EnableRaisingEvents = true;
// wire up an event handler
proc.Exit += new EventHandler(proc_Exit);
}
private void proc_Exit()
{
Application.Exit();
}
lbolognini@gmail.com wrote:
> Hi all,
>
> got this code inside a Windows Form 1.1 that opens a file with Notepad:
>
> System.Diagnostics.Process proc = new System.Diagnostics.Process();
> proc.EnableRaisingEvents = true;
> proc.StartInfo.FileName = "Notepad";
> proc.StartInfo.Arguments =
> " C:\\WINDOWS\\system32\\drivers\\etc\\hos
ts";
> proc.Start();
> if (proc.HasExited == true)
> {
> //why doesn't this work?
> Application.Exit();
> }
>
> Why isn't the application exiting when I close Notepad? How do i make
> it behave like that?
>
> Thanks,
> Lorenzo
| |
| lbolognini@gmail.com 2006-06-29, 4:00 am |
|
Josh Twist wrote:
> // wire up an event handler
> proc.Exit += new EventHandler(proc_Exit);
> }
>
> private void proc_Exit()
> {
> Application.Exit();
> }
Thanks Josh,
Lorenzo
| |
|
|
|
|