所以我發現啓動另一個應用程序,但沒有新的進程
System.Diagnostics.Process.Start()
但是,後來我想關閉應用程序,它開始工作(這是需要我啓動連接到服務器,啓動遊戲,並關閉自身),所以它不起作用。 我的應用程序:
public partial class MainWindow : Window
{
Process.Start("xnagame.exe", "12345678");
this.Close();
}
所以我發現啓動另一個應用程序,但沒有新的進程
System.Diagnostics.Process.Start()
但是,後來我想關閉應用程序,它開始工作(這是需要我啓動連接到服務器,啓動遊戲,並關閉自身),所以它不起作用。 我的應用程序:
public partial class MainWindow : Window
{
Process.Start("xnagame.exe", "12345678");
this.Close();
}
名稱的過程,所以你有一個手柄將其關閉。並非所有進程都優雅地關閉。
try
{
Process myProcess;
myProcess = Process.Start("Notepad.exe");
// Display physical memory usage 5 times at intervals of 2 seconds.
for (int i = 0;i < 5; i++)
{
if (!myProcess.HasExited)
{
// Discard cached information about the process.
myProcess.Refresh();
// Print working set to console.
Console.WriteLine("Physical Memory Usage: "
+ myProcess.WorkingSet.ToString());
// Wait 2 seconds.
Thread.Sleep(2000);
}
else {
break;
}
}
// Close process by sending a close message to its main window.
myProcess.CloseMainWindow();
// Free resources associated with process.
myProcess.Close();
}
catch(Exception e)
{
Console.WriteLine("The following exception was raised: ");
Console.WriteLine(e.Message);
}
使用Process.Start(ProcessStartInfo)
過載,而UseShellExecute
屬性設置爲true
。
'應用程序==過程' –
另外,什麼「不工作」?發生了什麼,你想要什麼? –
也許「不起作用」是指代碼不能編譯:) – Steve