Process.SynchronizingObject Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
İşlem çıkış olayının sonucu olarak verilen olay işleyici çağrılarını sıralamak için kullanılan nesneyi alır veya ayarlar.
public:
property System::ComponentModel::ISynchronizeInvoke ^ SynchronizingObject { System::ComponentModel::ISynchronizeInvoke ^ get(); void set(System::ComponentModel::ISynchronizeInvoke ^ value); };
public System.ComponentModel.ISynchronizeInvoke? SynchronizingObject { get; set; }
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get; set; }
[System.ComponentModel.Browsable(false)]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get; set; }
member this.SynchronizingObject : System.ComponentModel.ISynchronizeInvoke with get, set
[<System.ComponentModel.Browsable(false)>]
member this.SynchronizingObject : System.ComponentModel.ISynchronizeInvoke with get, set
Public Property SynchronizingObject As ISynchronizeInvoke
Özellik Değeri
İşlemdeki ISynchronizeInvoke bir Exited olayın sonucu olarak verilen olay işleyici çağrılarını sıralamak için kullanılır.
- Öznitelikler
Örnekler
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
{
}
Private button1 As MyButton
Private Sub button1_Click(sender As Object, e As EventArgs)
Using myProcess As New Process()
Dim myProcessStartInfo As New ProcessStartInfo("mspaint")
myProcess.StartInfo = myProcessStartInfo
myProcess.Start()
AddHandler myProcess.Exited, AddressOf 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()
End Using
End Sub
Private Sub MyProcessExited(source As Object, e As EventArgs)
MessageBox.Show("The process has exited.")
End Sub
End Class
Public Class MyButton
Inherits Button
End Class
Açıklamalar
olduğunda SynchronizingObjectnull, olayı işleyen Exited yöntemler sistem iş parçacığı havuzundan bir iş parçacığında çağrılır. Sistem iş parçacığı havuzları hakkında daha fazla bilgi için bkz ThreadPool. .
Exited Olay, gibi Buttonbir görsel Windows Forms bileşeni tarafından işlendiğinde, bileşene sistem iş parçacığı havuzu üzerinden erişilmeyebilir veya bir özel durumla sonuçlanabilir. Olayı işleyen Exited yöntemlerin bileşenin oluşturulduğu iş parçacığında çağrılmasını sağlayan bir Windows Forms bileşenine ayar SynchronizingObject yaparak bundan kaçının.
Process Bir Windows Forms tasarımcısında Visual Studio 2005 içinde kullanılıyorsa, SynchronizingObject otomatik olarak öğesini içeren Processdenetime ayarlanır. Örneğin, için bir Process tasarımcıya yerleştirirseniz (öğesinden Formdevralır) SynchronizingObject özelliği Process örneği Form1olarak Form1 ayarlanır:
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;
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;
process1.StartInfo.Domain = ""
process1.StartInfo.LoadUserProfile = False
process1.StartInfo.Password = Nothing
process1.StartInfo.StandardErrorEncoding = Nothing
process1.StartInfo.StandardOutputEncoding = Nothing
process1.StartInfo.UserName = ""
process1.SynchronizingObject = Me
Bu özellik genellikle bileşen bir denetim veya forma yerleştirildiğinde ayarlanır çünkü bu bileşenler belirli bir iş parçacığına bağlıdır.