WaitHandle.SignalAndWait WaitHandle.SignalAndWait WaitHandle.SignalAndWait WaitHandle.SignalAndWait Method

定義

1 つの WaitHandle を通知し、別のハンドルを待機します。 Signals one WaitHandle and waits on another.

オーバーロード

SignalAndWait(WaitHandle, WaitHandle) SignalAndWait(WaitHandle, WaitHandle) SignalAndWait(WaitHandle, WaitHandle) SignalAndWait(WaitHandle, WaitHandle)

1 つの WaitHandle を通知し、別のハンドルを待機します。 Signals one WaitHandle and waits on another.

SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean) SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean) SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean) SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean)

1 つの WaitHandle を通知し、別のハンドルを待機します。タイムアウト間隔として 32 ビット符号付き整数を指定し、待機に入る前にコンテキストの同期ドメインを終了するかどうかを指定します。 Signals one WaitHandle and waits on another, specifying a time-out interval as a 32-bit signed integer and specifying whether to exit the synchronization domain for the context before entering the wait.

SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean) SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean) SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean) SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean)

1 つの WaitHandle を通知し、別のハンドルを待機します。タイムアウト間隔として TimeSpan を指定し、待機に入る前にコンテキストの同期ドメインを終了するかどうかを指定します。 Signals one WaitHandle and waits on another, specifying the time-out interval as a TimeSpan and specifying whether to exit the synchronization domain for the context before entering the wait.

SignalAndWait(WaitHandle, WaitHandle) SignalAndWait(WaitHandle, WaitHandle) SignalAndWait(WaitHandle, WaitHandle) SignalAndWait(WaitHandle, WaitHandle)

1 つの WaitHandle を通知し、別のハンドルを待機します。 Signals one WaitHandle and waits on another.

public:
 static bool SignalAndWait(System::Threading::WaitHandle ^ toSignal, System::Threading::WaitHandle ^ toWaitOn);
public static bool SignalAndWait (System.Threading.WaitHandle toSignal, System.Threading.WaitHandle toWaitOn);
static member SignalAndWait : System.Threading.WaitHandle * System.Threading.WaitHandle -> bool
Public Shared Function SignalAndWait (toSignal As WaitHandle, toWaitOn As WaitHandle) As Boolean
パラメーター
toSignal
WaitHandle WaitHandle WaitHandle WaitHandle

通知対象の WaitHandle The WaitHandle to signal.

toWaitOn
WaitHandle WaitHandle WaitHandle WaitHandle

待機対象の WaitHandle The WaitHandle to wait on.

戻り値

通知と待機の両方が正常に完了した場合は true。待機が完了しない場合、メソッドから制御は戻りません。 true if both the signal and the wait complete successfully; if the wait does not complete, the method does not return.

例外

toSignalnullです。 toSignal is null. - または - -or- toWaitOnnullです。 toWaitOn is null.

メソッドは STAThreadAttribute を持つスレッドで呼び出されました。 The method was called on a thread that has STAThreadAttribute.

このメソッドは、Windows 98 および Windows Millennium Edition ではサポートされていません。 This method is not supported on Windows 98 or Windows Millennium Edition.

toSignal はセマフォで、カウントは既に最大値になっています。 toSignal is a semaphore, and it already has a full count.

スレッドがミューテックスを解放せずに終了したため、待機が完了しました。 The wait completed because a thread exited without releasing a mutex. Windows 98 または Windows Millennium Edition では、この例外はスローされません。 This exception is not thrown on Windows 98 or Windows Millennium Edition.

次のコード例では、SignalAndWait(WaitHandle, WaitHandle)ブロックされたスレッドのシグナルを待ってから、スレッドがタスクを完了するまでメイン スレッドを許可するメソッドのオーバー ロードします。The following code example uses the SignalAndWait(WaitHandle, WaitHandle) method overload to allow the main thread to signal a blocked thread and then wait until the thread finishes a task.

例では、5 つのスレッドを開始、ブロックすることができます、EventWaitHandleで作成された、EventResetMode.AutoResetフラグ、およびユーザーが ENTER キーを押す、リリースの 1 つのスレッド時間。The example starts five threads, allows them to block on an EventWaitHandle created with the EventResetMode.AutoReset flag, and then releases one thread each time the user presses the ENTER key. 例では、別の 5 つのスレッドのキューし、すべてを使用して、解放、EventWaitHandleで作成された、EventResetMode.ManualResetフラグ。The example then queues another five threads and releases them all using an EventWaitHandle created with the EventResetMode.ManualReset flag.

using namespace System;
using namespace System::Threading;

public ref class Example
{
private:
   // The EventWaitHandle used to demonstrate the difference
   // between AutoReset and ManualReset synchronization events.
   //
   static EventWaitHandle^ ewh;

   // A counter to make sure all threads are started and
   // blocked before any are released. A Long is used to show
   // the use of the 64-bit Interlocked methods.
   //
   static __int64 threadCount = 0;

   // An AutoReset event that allows the main thread to block
   // until an exiting thread has decremented the count.
   //
   static EventWaitHandle^ clearCount =
      gcnew EventWaitHandle( false,EventResetMode::AutoReset );

public:
   [MTAThread]
   static void main()
   {
      // Create an AutoReset EventWaitHandle.
      //
      ewh = gcnew EventWaitHandle( false,EventResetMode::AutoReset );
      
      // Create and start five numbered threads. Use the
      // ParameterizedThreadStart delegate, so the thread
      // number can be passed as an argument to the Start
      // method.
      for ( int i = 0; i <= 4; i++ )
      {
         Thread^ t = gcnew Thread(
            gcnew ParameterizedThreadStart( ThreadProc ) );
         t->Start( i );
      }
      
      // Wait until all the threads have started and blocked.
      // When multiple threads use a 64-bit value on a 32-bit
      // system, you must access the value through the
      // Interlocked class to guarantee thread safety.
      //
      while ( Interlocked::Read( threadCount ) < 5 )
      {
         Thread::Sleep( 500 );
      }

      // Release one thread each time the user presses ENTER,
      // until all threads have been released.
      //
      while ( Interlocked::Read( threadCount ) > 0 )
      {
         Console::WriteLine( L"Press ENTER to release a waiting thread." );
         Console::ReadLine();
         
         // SignalAndWait signals the EventWaitHandle, which
         // releases exactly one thread before resetting,
         // because it was created with AutoReset mode.
         // SignalAndWait then blocks on clearCount, to
         // allow the signaled thread to decrement the count
         // before looping again.
         //
         WaitHandle::SignalAndWait( ewh, clearCount );
      }
      Console::WriteLine();
      
      // Create a ManualReset EventWaitHandle.
      //
      ewh = gcnew EventWaitHandle( false,EventResetMode::ManualReset );
      
      // Create and start five more numbered threads.
      //
      for ( int i = 0; i <= 4; i++ )
      {
         Thread^ t = gcnew Thread(
            gcnew ParameterizedThreadStart( ThreadProc ) );
         t->Start( i );
      }
      
      // Wait until all the threads have started and blocked.
      //
      while ( Interlocked::Read( threadCount ) < 5 )
      {
         Thread::Sleep( 500 );
      }

      // Because the EventWaitHandle was created with
      // ManualReset mode, signaling it releases all the
      // waiting threads.
      //
      Console::WriteLine( L"Press ENTER to release the waiting threads." );
      Console::ReadLine();
      ewh->Set();

   }

   static void ThreadProc( Object^ data )
   {
      int index = static_cast<Int32>(data);

      Console::WriteLine( L"Thread {0} blocks.", data );
      // Increment the count of blocked threads.
      Interlocked::Increment( threadCount );
      
      // Wait on the EventWaitHandle.
      ewh->WaitOne();

      Console::WriteLine( L"Thread {0} exits.", data );
      // Decrement the count of blocked threads.
      Interlocked::Decrement( threadCount );
      
      // After signaling ewh, the main thread blocks on
      // clearCount until the signaled thread has
      // decremented the count. Signal it now.
      //
      clearCount->Set();
   }
};
using System;
using System.Threading;

public class Example
{
    // The EventWaitHandle used to demonstrate the difference
    // between AutoReset and ManualReset synchronization events.
    //
    private static EventWaitHandle ewh;

    // A counter to make sure all threads are started and
    // blocked before any are released. A Long is used to show
    // the use of the 64-bit Interlocked methods.
    //
    private static long threadCount = 0;

    // An AutoReset event that allows the main thread to block
    // until an exiting thread has decremented the count.
    //
    private static EventWaitHandle clearCount = 
        new EventWaitHandle(false, EventResetMode.AutoReset);

    [MTAThread]
    public static void Main()
    {
        // Create an AutoReset EventWaitHandle.
        //
        ewh = new EventWaitHandle(false, EventResetMode.AutoReset);

        // Create and start five numbered threads. Use the
        // ParameterizedThreadStart delegate, so the thread
        // number can be passed as an argument to the Start 
        // method.
        for (int i = 0; i <= 4; i++)
        {
            Thread t = new Thread(
                new ParameterizedThreadStart(ThreadProc)
            );
            t.Start(i);
        }

        // Wait until all the threads have started and blocked.
        // When multiple threads use a 64-bit value on a 32-bit
        // system, you must access the value through the
        // Interlocked class to guarantee thread safety.
        //
        while (Interlocked.Read(ref threadCount) < 5)
        {
            Thread.Sleep(500);
        }

        // Release one thread each time the user presses ENTER,
        // until all threads have been released.
        //
        while (Interlocked.Read(ref threadCount) > 0)
        {
            Console.WriteLine("Press ENTER to release a waiting thread.");
            Console.ReadLine();

            // SignalAndWait signals the EventWaitHandle, which
            // releases exactly one thread before resetting, 
            // because it was created with AutoReset mode. 
            // SignalAndWait then blocks on clearCount, to 
            // allow the signaled thread to decrement the count
            // before looping again.
            //
            WaitHandle.SignalAndWait(ewh, clearCount);
        }
        Console.WriteLine();

        // Create a ManualReset EventWaitHandle.
        //
        ewh = new EventWaitHandle(false, EventResetMode.ManualReset);

        // Create and start five more numbered threads.
        //
        for(int i=0; i<=4; i++)
        {
            Thread t = new Thread(
                new ParameterizedThreadStart(ThreadProc)
            );
            t.Start(i);
        }

        // Wait until all the threads have started and blocked.
        //
        while (Interlocked.Read(ref threadCount) < 5)
        {
            Thread.Sleep(500);
        }

        // Because the EventWaitHandle was created with
        // ManualReset mode, signaling it releases all the
        // waiting threads.
        //
        Console.WriteLine("Press ENTER to release the waiting threads.");
        Console.ReadLine();
        ewh.Set();
        
    }

    public static void ThreadProc(object data)
    {
        int index = (int) data;

        Console.WriteLine("Thread {0} blocks.", data);
        // Increment the count of blocked threads.
        Interlocked.Increment(ref threadCount);

        // Wait on the EventWaitHandle.
        ewh.WaitOne();

        Console.WriteLine("Thread {0} exits.", data);
        // Decrement the count of blocked threads.
        Interlocked.Decrement(ref threadCount);

        // After signaling ewh, the main thread blocks on
        // clearCount until the signaled thread has 
        // decremented the count. Signal it now.
        //
        clearCount.Set();
    }
}
Imports System
Imports System.Threading

Public Class Example

    ' The EventWaitHandle used to demonstrate the difference
    ' between AutoReset and ManualReset synchronization events.
    '
    Private Shared ewh As EventWaitHandle

    ' A counter to make sure all threads are started and
    ' blocked before any are released. A Long is used to show
    ' the use of the 64-bit Interlocked methods.
    '
    Private Shared threadCount As Long = 0

    ' An AutoReset event that allows the main thread to block
    ' until an exiting thread has decremented the count.
    '
    Private Shared clearCount As New EventWaitHandle(False, _
        EventResetMode.AutoReset)

    <MTAThread> _
    Public Shared Sub Main()

        ' Create an AutoReset EventWaitHandle.
        '
        ewh = New EventWaitHandle(False, EventResetMode.AutoReset)

        ' Create and start five numbered threads. Use the
        ' ParameterizedThreadStart delegate, so the thread
        ' number can be passed as an argument to the Start 
        ' method.
        For i As Integer = 0 To 4
            Dim t As New Thread(AddressOf ThreadProc)
            t.Start(i)
        Next i

        ' Wait until all the threads have started and blocked.
        ' When multiple threads use a 64-bit value on a 32-bit
        ' system, you must access the value through the
        ' Interlocked class to guarantee thread safety.
        '
        While Interlocked.Read(threadCount) < 5
            Thread.Sleep(500)
        End While

        ' Release one thread each time the user presses ENTER,
        ' until all threads have been released.
        '
        While Interlocked.Read(threadCount) > 0
            Console.WriteLine("Press ENTER to release a waiting thread.")
            Console.ReadLine()

            ' SignalAndWait signals the EventWaitHandle, which
            ' releases exactly one thread before resetting, 
            ' because it was created with AutoReset mode. 
            ' SignalAndWait then blocks on clearCount, to 
            ' allow the signaled thread to decrement the count
            ' before looping again.
            '
            WaitHandle.SignalAndWait(ewh, clearCount)
        End While
        Console.WriteLine()

        ' Create a ManualReset EventWaitHandle.
        '
        ewh = New EventWaitHandle(False, EventResetMode.ManualReset)

        ' Create and start five more numbered threads.
        '
        For i As Integer = 0 To 4
            Dim t As New Thread(AddressOf ThreadProc)
            t.Start(i)
        Next i

        ' Wait until all the threads have started and blocked.
        '
        While Interlocked.Read(threadCount) < 5
            Thread.Sleep(500)
        End While

        ' Because the EventWaitHandle was created with
        ' ManualReset mode, signaling it releases all the
        ' waiting threads.
        '
        Console.WriteLine("Press ENTER to release the waiting threads.")
        Console.ReadLine()
        ewh.Set()
        
    End Sub

    Public Shared Sub ThreadProc(ByVal data As Object)
        Dim index As Integer = CInt(data)

        Console.WriteLine("Thread {0} blocks.", data)
        ' Increment the count of blocked threads.
        Interlocked.Increment(threadCount)

        ' Wait on the EventWaitHandle.
        ewh.WaitOne()

        Console.WriteLine("Thread {0} exits.", data)
        ' Decrement the count of blocked threads.
        Interlocked.Decrement(threadCount)

        ' After signaling ewh, the main thread blocks on
        ' clearCount until the signaled thread has 
        ' decremented the count. Signal it now.
        '
        clearCount.Set()
    End Sub
End Class

注釈

この操作はアトミックであるは保証されません。This operation is not guaranteed to be atomic. 現在のスレッドの信号後toSignalまでの間待機しているtoWaitOn、別のプロセッサで実行されているスレッドを通知toWaitOn待機またはします。After the current thread signals toSignal but before it waits on toWaitOn, a thread that is running on another processor might signal toWaitOn or wait on it.

SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean) SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean) SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean) SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean)

1 つの WaitHandle を通知し、別のハンドルを待機します。タイムアウト間隔として 32 ビット符号付き整数を指定し、待機に入る前にコンテキストの同期ドメインを終了するかどうかを指定します。 Signals one WaitHandle and waits on another, specifying a time-out interval as a 32-bit signed integer and specifying whether to exit the synchronization domain for the context before entering the wait.

public:
 static bool SignalAndWait(System::Threading::WaitHandle ^ toSignal, System::Threading::WaitHandle ^ toWaitOn, int millisecondsTimeout, bool exitContext);
public static bool SignalAndWait (System.Threading.WaitHandle toSignal, System.Threading.WaitHandle toWaitOn, int millisecondsTimeout, bool exitContext);
static member SignalAndWait : System.Threading.WaitHandle * System.Threading.WaitHandle * int * bool -> bool
Public Shared Function SignalAndWait (toSignal As WaitHandle, toWaitOn As WaitHandle, millisecondsTimeout As Integer, exitContext As Boolean) As Boolean
パラメーター
toSignal
WaitHandle WaitHandle WaitHandle WaitHandle

通知対象の WaitHandle The WaitHandle to signal.

toWaitOn
WaitHandle WaitHandle WaitHandle WaitHandle

待機対象の WaitHandle The WaitHandle to wait on.

millisecondsTimeout
Int32 Int32 Int32 Int32

待機する間隔を表す整数。 An integer that represents the interval to wait. この値が Infinite、つまり -1 の場合、待機は無期限となります。 If the value is Infinite, that is, -1, the wait is infinite.

exitContext
Boolean Boolean Boolean Boolean

待機する前にコンテキストの同期ドメインを終了し (同期されたコンテキスト内にいる場合)、後で再取得する場合は、true。それ以外の場合は false true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.

戻り値

通知および待機の両方が正常に完了した場合は true。通知は完了したが、待機がタイムアウトになった場合は false true if both the signal and the wait completed successfully, or false if the signal completed but the wait timed out.

例外

toSignalnullです。 toSignal is null. - または - -or- toWaitOnnullです。 toWaitOn is null.

メソッドは STAThreadAttribute を持つスレッドで呼び出されます。 The method is called on a thread that has STAThreadAttribute.

このメソッドは、Windows 98 および Windows Millennium Edition ではサポートされていません。 This method is not supported on Windows 98 or Windows Millennium Edition.

カウントの最大値を超えるため、WaitHandle はシグナル状態にはできません。 The WaitHandle cannot be signaled because it would exceed its maximum count.

millisecondsTimeout は無限のタイムアウトを表す -1 以外の負の数です。 millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

スレッドがミューテックスを解放せずに終了したため、待機が完了しました。 The wait completed because a thread exited without releasing a mutex. Windows 98 または Windows Millennium Edition では、この例外はスローされません。 This exception is not thrown on Windows 98 or Windows Millennium Edition.

注釈

この操作はアトミックであるは保証されません。This operation is not guaranteed to be atomic. 現在のスレッドの信号後toSignalまでの間待機しているtoWaitOn、別のプロセッサで実行されているスレッドを通知toWaitOn待機またはします。After the current thread signals toSignal but before it waits on toWaitOn, a thread that is running on another processor might signal toWaitOn or wait on it.

場合millisecondsTimeoutが 0 の場合、メソッドはブロックしません。If millisecondsTimeout is zero, the method does not block. テストの状態、toWaitOnをすぐに返します。It tests the state of the toWaitOn and returns immediately.

コンテキストの終了時の注意Notes on Exiting the Context

exitContextパラメーターには効果がない場合を除き、SignalAndWait既定以外の管理対象のコンテキスト内からメソッドが呼び出されます。The exitContext parameter has no effect unless the SignalAndWait method is called from inside a nondefault managed context. 派生したクラスのインスタンスへの呼び出し、スレッドが場合に生じるContextBoundObjectします。This can happen if your thread is inside a call to an instance of a class derived from ContextBoundObject. 派生していないクラスでメソッドを現在実行している場合でもContextBoundObjectと同様に、 String、既定以外のコンテキストであることができる場合、ContextBoundObjectが現在のアプリケーション ドメインで、スタック上にします。Even if you are currently executing a method on a class that does not derive from ContextBoundObject, like String, you can be in a nondefault context if a ContextBoundObject is on your stack in the current application domain.

既定以外のコンテキストでコードを実行しているときに指定するtrueexitContextが原因で、既定以外の管理コンテキストを終了するスレッド (つまり、既定のコンテキストへの移行) 実行する前に、SignalAndWaitメソッド。When your code is executing in a nondefault context, specifying true for exitContext causes the thread to exit the nondefault managed context (that is, to transition to the default context) before executing the SignalAndWait method. 呼び出し後、スレッドが元の既定以外のコンテキストに戻る、SignalAndWaitメソッドが完了するとします。The thread returns to the original nondefault context after the call to the SignalAndWait method completes.

これは、便利な場合、コンテキスト バインド クラスにはSynchronizationAttributeします。This can be useful when the context-bound class has SynchronizationAttribute. その場合は、クラスのメンバーに対するすべての呼び出しを自動的に同期し、同期ドメインは、クラスのコードの本文全体。In that case, all calls to members of the class are automatically synchronized, and the synchronization domain is the entire body of code for the class. メンバーの呼び出し履歴内のコードを呼び出すかどうか、SignalAndWaitメソッドを指定してtrueexitContextスレッドが続行する、オブジェクトのすべてのメンバーへの呼び出しでブロックされているスレッドを許可する、同期ドメインを終了します。If code in the call stack of a member calls the SignalAndWait method and specifies true for exitContext, the thread exits the synchronization domain, allowing a thread that is blocked on a call to any member of the object to proceed. ときに、SignalAndWaitメソッドが戻る呼び出しを行ったスレッドが同期ドメインを再入力を待つ必要があります。When the SignalAndWait method returns, the thread that made the call must wait to reenter the synchronization domain.

SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean) SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean) SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean) SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean)

1 つの WaitHandle を通知し、別のハンドルを待機します。タイムアウト間隔として TimeSpan を指定し、待機に入る前にコンテキストの同期ドメインを終了するかどうかを指定します。 Signals one WaitHandle and waits on another, specifying the time-out interval as a TimeSpan and specifying whether to exit the synchronization domain for the context before entering the wait.

public:
 static bool SignalAndWait(System::Threading::WaitHandle ^ toSignal, System::Threading::WaitHandle ^ toWaitOn, TimeSpan timeout, bool exitContext);
public static bool SignalAndWait (System.Threading.WaitHandle toSignal, System.Threading.WaitHandle toWaitOn, TimeSpan timeout, bool exitContext);
static member SignalAndWait : System.Threading.WaitHandle * System.Threading.WaitHandle * TimeSpan * bool -> bool
Public Shared Function SignalAndWait (toSignal As WaitHandle, toWaitOn As WaitHandle, timeout As TimeSpan, exitContext As Boolean) As Boolean
パラメーター
toSignal
WaitHandle WaitHandle WaitHandle WaitHandle

通知対象の WaitHandle The WaitHandle to signal.

toWaitOn
WaitHandle WaitHandle WaitHandle WaitHandle

待機対象の WaitHandle The WaitHandle to wait on.

timeout
TimeSpan TimeSpan TimeSpan TimeSpan

待機間隔を表す TimeSpan A TimeSpan that represents the interval to wait. この値が -1 の場合、待機は無期限となります。 If the value is -1, the wait is infinite.

exitContext
Boolean Boolean Boolean Boolean

待機する前にコンテキストの同期ドメインを終了し (同期されたコンテキスト内にいる場合)、後で再取得する場合は、true。それ以外の場合は false true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.

戻り値

通知および待機の両方が正常に完了した場合は true。通知は完了したが、待機がタイムアウトになった場合は false true if both the signal and the wait completed successfully, or false if the signal completed but the wait timed out.

例外

toSignalnullです。 toSignal is null. - または - -or- toWaitOnnullです。 toWaitOn is null.

メソッドは STAThreadAttribute を持つスレッドで呼び出されました。 The method was called on a thread that has STAThreadAttribute.

このメソッドは、Windows 98 および Windows Millennium Edition ではサポートされていません。 This method is not supported on Windows 98 or Windows Millennium Edition.

toSignal はセマフォで、カウントは既に最大値になっています。 toSignal is a semaphore, and it already has a full count.

timeout は、-1 以外の負のミリ秒値となります。 timeout evaluates to a negative number of milliseconds other than -1. - または - -or- timeoutMaxValue より大きくなっています。 timeout is greater than MaxValue.

スレッドがミューテックスを解放せずに終了したため、待機が完了しました。 The wait completed because a thread exited without releasing a mutex. Windows 98 または Windows Millennium Edition では、この例外はスローされません。 This exception is not thrown on Windows 98 or Windows Millennium Edition.

注釈

この操作はアトミックであるは保証されません。This operation is not guaranteed to be atomic. 現在のスレッドの信号後toSignalまでの間待機しているtoWaitOn、別のプロセッサで実行されているスレッドを通知toWaitOn待機またはします。After the current thread signals toSignal but before it waits on toWaitOn, a thread that is running on another processor might signal toWaitOn or wait on it.

最大値timeoutInt32.MaxValueします。The maximum value for timeout is Int32.MaxValue.

場合timeoutが 0 の場合、メソッドはブロックしません。If timeout is zero, the method does not block. テストの状態、toWaitOnをすぐに返します。It tests the state of the toWaitOn and returns immediately.

コンテキストの終了時の注意Notes on Exiting the Context

exitContextパラメーターには効果がない場合を除き、SignalAndWait既定以外の管理対象のコンテキスト内からメソッドが呼び出されます。The exitContext parameter has no effect unless the SignalAndWait method is called from inside a nondefault managed context. 派生したクラスのインスタンスへの呼び出し、スレッドが場合に生じるContextBoundObjectします。This can happen if your thread is inside a call to an instance of a class derived from ContextBoundObject. 派生していないクラスでメソッドを現在実行している場合でもContextBoundObjectと同様に、 String、既定以外のコンテキストであることができる場合、ContextBoundObjectが現在のアプリケーション ドメインで、スタック上にします。Even if you are currently executing a method on a class that does not derive from ContextBoundObject, like String, you can be in a nondefault context if a ContextBoundObject is on your stack in the current application domain.

既定以外のコンテキストでコードを実行しているときに指定するtrueexitContextが原因で、既定以外の管理コンテキストを終了するスレッド (つまり、既定のコンテキストへの移行) 実行する前に、SignalAndWaitメソッド。When your code is executing in a nondefault context, specifying true for exitContext causes the thread to exit the nondefault managed context (that is, to transition to the default context) before executing the SignalAndWait method. 呼び出し後、スレッドが元の既定以外のコンテキストに戻る、SignalAndWaitメソッドが完了するとします。The thread returns to the original nondefault context after the call to the SignalAndWait method completes.

これは、便利な場合、コンテキスト バインド クラスにはSynchronizationAttributeします。This can be useful when the context-bound class has SynchronizationAttribute. その場合は、クラスのメンバーに対するすべての呼び出しを自動的に同期し、同期ドメインは、クラスのコードの本文全体。In that case, all calls to members of the class are automatically synchronized, and the synchronization domain is the entire body of code for the class. メンバーの呼び出し履歴内のコードを呼び出すかどうか、SignalAndWaitメソッドを指定してtrueexitContextスレッドが続行する、オブジェクトのすべてのメンバーへの呼び出しでブロックされているスレッドを許可する、同期ドメインを終了します。If code in the call stack of a member calls the SignalAndWait method and specifies true for exitContext, the thread exits the synchronization domain, allowing a thread that is blocked on a call to any member of the object to proceed. ときに、SignalAndWaitメソッドが戻る呼び出しを行ったスレッドが同期ドメインを再入力を待つ必要があります。When the SignalAndWait method returns, the thread that made the call must wait to reenter the synchronization domain.

適用対象