Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft das Objekt ab, das zum Marshallen der Ereignishandleraufrufe verwendet wird, die als Ergebnis eines Prozessbeendigungsereignisses ausgegeben werden, oder legt dieses fest.
Namespace: System.Diagnostics
Assembly: System (in system.dll)
Syntax
'Declaration
Public Property SynchronizingObject As ISynchronizeInvoke
'Usage
Dim instance As Process
Dim value As ISynchronizeInvoke
value = instance.SynchronizingObject
instance.SynchronizingObject = value
public ISynchronizeInvoke SynchronizingObject { get; set; }
public:
property ISynchronizeInvoke^ SynchronizingObject {
ISynchronizeInvoke^ get ();
void set (ISynchronizeInvoke^ value);
}
/** @property */
public ISynchronizeInvoke get_SynchronizingObject ()
/** @property */
public void set_SynchronizingObject (ISynchronizeInvoke value)
public function get SynchronizingObject () : ISynchronizeInvoke
public function set SynchronizingObject (value : ISynchronizeInvoke)
Eigenschaftenwert
Das ISynchronizeInvoke, das zum Marshallen von Ereignishandleraufrufen verwendet wird, die als Ergebnis eines Exited-Ereignisses des Prozesses ausgegeben werden.
Hinweise
Wenn SynchronizingObject den Wert NULL (Nothing in Visual Basic) aufweist, werden die Methoden für das Behandeln des Exited-Ereignisses in einem Thread aus dem Threadpool des Systems aufgerufen. Weitere Informationen über Threadpools des Systems finden Sie unter ThreadPool.
Wenn das Exited-Ereignis von einer visuellen Windows Forms-Komponente behandelt wird, z. B. einem Button, ist die Komponente möglicherweise nicht über den Threadpool des Systems zugänglich, oder es wird eine Ausnahme ausgelöst. Dies können Sie vermeiden, indem Sie SynchronizingObject auf eine Windows Forms-Komponente festlegen, durch die Methoden zur Behandlung des Exited-Ereignisses in demselben Thread aufgerufen werden, in dem die Komponente erstellt wurde.
Wenn Process innerhalb von Visual Studio 2005 in einem Windows Forms-Designer verwendet wird, ist SynchronizingObject automatisch auf das Steuerelement festgelegt, das Process enthält. Wenn Sie beispielsweise einen Process in einem Designer für Form1 platzieren (das von Form erbt), wird die SynchronizingObject-Eigenschaft von Process auf eine Instanz von Form1 festgelegt.
Diese Eigenschaft wird normalerweise dann festgelegt, wenn die Komponente in einem Steuerelement oder Formular platziert wird, da diese Komponenten an einen bestimmten Thread gebunden sind.
Beispiel
Private button1 As MyButton
Private Sub button1_Click(sender As Object, e As EventArgs)
Dim 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()
myProcess.Close()
End Sub 'button1_Click
Private Sub MyProcessExited(source As Object, e As EventArgs)
MessageBox.Show("The process has exited.")
End Sub 'MyProcessExited
End Class 'Form1
Public Class MyButton
Inherits Button
End Class 'MyButton
private MyButton button1;
private void button1_Click(object sender, System.EventArgs e)
{
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();
myProcess.Close();
}
private void MyProcessExited(Object source, EventArgs e)
{
MessageBox.Show("The process has exited.");
}
}
public class MyButton:Button
{
}
ref class MyButton: public Button
{
public:
void MyProcessExited( Object^ source, EventArgs^ e )
{
MessageBox::Show( "The process has exited." );
}
};
public:
MyButton^ button1;
private:
void MyProcessExited( Object^ source, EventArgs^ e )
{
MessageBox::Show( "The process has exited." );
}
void button1_Click( Object^ sender, EventArgs^ e )
{
Process^ myProcess = gcnew Process;
ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "mspaint" );
myProcess->StartInfo = myProcessStartInfo;
myProcess->Start();
myProcess->Exited += gcnew System::EventHandler( this, &Form1::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();
myProcess->Close();
}
private MyButton button1;
private void button1_Click(Object sender, System.EventArgs e)
{
System.Diagnostics.Process myProcess =
new System.Diagnostics.Process();
ProcessStartInfo myProcessStartInfo =
new ProcessStartInfo("mspaint");
myProcess.set_StartInfo(myProcessStartInfo);
myProcess.Start();
myProcess.add_Exited(new EventHandler(MyProcessExited));
// Set 'EnableRaisingEvents' to true, to raise 'Exited' event when
// process is terminated.
myProcess.set_EnableRaisingEvents(true);
// Set method handling the exited event to be called;
// on the same thread on which MyButton was created.
myProcess.set_SynchronizingObject(button1);
MessageBox.Show("Waiting for the process 'mspaint' to exit....");
myProcess.WaitForExit();
myProcess.Close();
} //button1_Click
private void MyProcessExited(Object source, EventArgs e)
{
MessageBox.Show("The process has exited.");
} //MyProcessExited
} //Form1
public class MyButton extends Button
{
.NET Framework-Sicherheit
- SecurityPermission zum Aufrufen von Process-Membern. Anforderungswert: LinkDemand; Benannte Berechtigungssätze: FullTrust.
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0