本文整理匯總了C#中System.Diagnostics.Process.SynchronizingObject屬性的典型用法代碼示例。如果您正苦於以下問題:C# Process.SynchronizingObject屬性的具體用法?C# Process.SynchronizingObject怎麽用?C# Process.SynchronizingObject使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Diagnostics.Process
的用法示例。
在下文中一共展示了Process.SynchronizingObject屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: button1_Click
private MyButton button1;
private void button1_Click(object sender, System.EventArgs e)
{
using (Process myProcess = new Process())
{
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("mspaint");
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
myProcess.Exited += new EventHandler(MyProcessExited);
// Set 'EnableRaisingEvents' to true, to raise 'Exited' event when process is terminated.
myProcess.EnableRaisingEvents = true;
// Set method handling the exited event to be called ;
// on the same thread on which MyButton was created.
myProcess.SynchronizingObject = button1;
MessageBox.Show("Waiting for the process 'mspaint' to exit....");
myProcess.WaitForExit();
}
}
private void MyProcessExited(Object source, EventArgs e)
{
MessageBox.Show("The process has exited.");
}
}
public class MyButton : Button
{
}
示例2:
process1.StartInfo.Domain = "";
process1.StartInfo.LoadUserProfile = false;
process1.StartInfo.Password = null;
process1.StartInfo.StandardErrorEncoding = null;
process1.StartInfo.StandardOutputEncoding = null;
process1.StartInfo.UserName = "";
process1.SynchronizingObject = this;