Process.SynchronizingObject プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Process.SynchronizingObject プロパティの意味・解説 

Process.SynchronizingObject プロパティ

プロセス終了イベント結果として発行されるイベント ハンドラ呼び出しマーシャリングするために使用するオブジェクト取得または設定します

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文構文

Public Property SynchronizingObject As
 ISynchronizeInvoke
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)

プロパティ
プロセスExited イベント結果として発行されるイベント ハンドラ呼び出しマーシャリングするために使用する ISynchronizeInvoke。

解説解説

SynchronizingObject が null 参照 (Visual Basic では Nothing) の場合Exited イベント処理するメソッドシステムスレッド プールスレッド呼び出されます。システム スレッド プール詳細については、ThreadPool のトピック参照してください

Exited イベントButton などのビジュアルな Windows フォーム コンポーネント処理するとき、システム スレッド プール通じてコンポーネントアクセスすると、適切に動作しなかったり、例外発生する場合あります。これを防ぐにはSynchronizingObjectWindows フォームコンポーネント設定してコンポーネント作成されているスレッドと同じスレッドExited イベント処理するメソッド呼び出されるようにします。

Visual Studio 2005 内部Windows フォーム デザイナProcess使用すると、SynchronizingObject には Process格納されているコントロール自動的に設定されます。たとえば、Form から継承される Form1 のデザイナProcess配置した場合ProcessSynchronizingObject プロパティには Form1 のインスタンス設定されます。

通常コンポーネントコントロールまたはフォーム中にあると、これらのコンポーネント特定のスレッドバインドされるため、このプロパティ設定されます。

使用例使用例
   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 のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からProcess.SynchronizingObject プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からProcess.SynchronizingObject プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からProcess.SynchronizingObject プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Process.SynchronizingObject プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Process.SynchronizingObject プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS