S
Sunny
Hi,
can someone confirm that this code is not working, and is there a reason
for this? (yes, I know for WaitForExit, this is just a sample, which
demonstrates that the event is not fired).
And ... the strange thing is, that if I uncomment the 3
Console.WriteLine statements which are before WaitOne statement, it
works as expected. But if I put comment on just one of them, the event
is not fired.
I'm using VS.Net 2003, framework 1.1, Win2K
Cheers
Sunny
using System;
using System.Diagnostics;
using System.Threading;
namespace signall
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Process getpub = new Process();
getpub.StartInfo =
new ProcessStartInfo(@"c:\winnt\system32\ipconfig.exe");
getpub.StartInfo.CreateNoWindow = true;
getpub.Exited += new EventHandler(getpub_Exited);
getpub.StartInfo.UseShellExecute = false;
getpub.StartInfo.RedirectStandardOutput = true;
getpub.StartInfo.RedirectStandardError = true;
getpub.Start();
//Console.WriteLine(getpub.StandardOutput.ReadToEnd
());
//Console.WriteLine(getpub.StandardError.ReadToEnd
());
//Console.WriteLine(getpub.HasExited.ToString());
processWait.WaitOne();
Console.WriteLine(getpub.ExitCode);
Console.WriteLine(getpub.StandardOutput.ReadToEnd
());
Console.ReadLine();
}
static AutoResetEvent processWait = new AutoResetEvent
(false);
private static void getpub_Exited(object sender, EventArgs
e)
{
Console.WriteLine("Process ended.");
processWait.Set();
}
}
}
can someone confirm that this code is not working, and is there a reason
for this? (yes, I know for WaitForExit, this is just a sample, which
demonstrates that the event is not fired).
And ... the strange thing is, that if I uncomment the 3
Console.WriteLine statements which are before WaitOne statement, it
works as expected. But if I put comment on just one of them, the event
is not fired.
I'm using VS.Net 2003, framework 1.1, Win2K
Cheers
Sunny
using System;
using System.Diagnostics;
using System.Threading;
namespace signall
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Process getpub = new Process();
getpub.StartInfo =
new ProcessStartInfo(@"c:\winnt\system32\ipconfig.exe");
getpub.StartInfo.CreateNoWindow = true;
getpub.Exited += new EventHandler(getpub_Exited);
getpub.StartInfo.UseShellExecute = false;
getpub.StartInfo.RedirectStandardOutput = true;
getpub.StartInfo.RedirectStandardError = true;
getpub.Start();
//Console.WriteLine(getpub.StandardOutput.ReadToEnd
());
//Console.WriteLine(getpub.StandardError.ReadToEnd
());
//Console.WriteLine(getpub.HasExited.ToString());
processWait.WaitOne();
Console.WriteLine(getpub.ExitCode);
Console.WriteLine(getpub.StandardOutput.ReadToEnd
());
Console.ReadLine();
}
static AutoResetEvent processWait = new AutoResetEvent
(false);
private static void getpub_Exited(object sender, EventArgs
e)
{
Console.WriteLine("Process ended.");
processWait.Set();
}
}
}