如何等待一个进程结束???
比如一个WinRAR进程在运行,该如何判断WinRAR进程是否结束,若WinRAR不结束则等待,直到WinRAR进程结束才继续下面的操作。谢谢 --------------------编程问答-------------------- 顶 --------------------编程问答--------------------
System.Diagnostics.Process p = new System.Diagnostics.Process();--------------------编程问答-------------------- namespace FileSystemWatcherExample
p.StartInfo.FileName = "mspaint";
p.Start();
p.WaitForExit();
MessageBox.Show("");
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// Create a new FileSystemWatcher and set its properties.
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = "E:\\Project\\C#组件熟悉\\窗体控件\\FileSystemWatcherExample";
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
// Only watch text files.
watcher.Filter = "test.txt";
// Add event handlers.
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);
watcher.Renamed += new RenamedEventHandler(OnRenamed);
// Begin watching.
watcher.EnableRaisingEvents = true;
// Wait for the user to quit the program.
}
// Define the event handlers.
private static void OnChanged(object source, FileSystemEventArgs e)
{
// Specify what is done when a file is changed, created, or deleted.
MessageBox.Show("File: " + e.FullPath + " " + e.ChangeType);
}
private static void OnRenamed(object source, RenamedEventArgs e)
{
// Specify what is done when a file is renamed.
MessageBox.Show("File:" + e.OldFullPath + "renamed to" + e.FullPath);
}
}
} --------------------编程问答-------------------- sign
补充:.NET技术 , C#