我有以下幾點:正確的事件處理程序來告訴我,當記事本關閉
class Program {
static void Main(string[] args) {
Process pr;
pr = new Process();
pr.StartInfo = new ProcessStartInfo(@"notepad.exe");
pr.Disposed += new EventHandler(YouClosedNotePad);
pr.Start();
Console.WriteLine("press [enter] to exit");
Console.ReadLine();
}
static void YouClosedNotePad(object sender, EventArgs e) {
Console.WriteLine("thanks for closing notepad");
}
}
當我關閉記事本我沒有得到我希望得到的消息 - 我怎麼修改,以便在返回的收盤記事本到控制檯?
@whytheq你確定嗎?它適用於我。順便說一句,正確答案+1。 –
ahhh--沒有看到其他的魔法代碼行! – whytheq
消息絕對應該在那裏。你是否啓用了事件? –