Thread.Suspend メソッド

定義

注意事項

Thread.Suspend has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. http://go.microsoft.com/fwlink/?linkid=14202

注意事項

Thread.Suspend has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. https://go.microsoft.com/fwlink/?linkid=14202

スレッドを中断するか、スレッドが既に中断されている場合は、効果はありません。

public:
 void Suspend();
public void Suspend();
[System.Obsolete("Thread.Suspend has been deprecated.  Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources.  http://go.microsoft.com/fwlink/?linkid=14202", false)]
public void Suspend();
[System.Obsolete("Thread.Suspend has been deprecated.  Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources.  https://go.microsoft.com/fwlink/?linkid=14202", false)]
public void Suspend();
member this.Suspend : unit -> unit
[<System.Obsolete("Thread.Suspend has been deprecated.  Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources.  http://go.microsoft.com/fwlink/?linkid=14202", false)>]
member this.Suspend : unit -> unit
[<System.Obsolete("Thread.Suspend has been deprecated.  Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources.  https://go.microsoft.com/fwlink/?linkid=14202", false)>]
member this.Suspend : unit -> unit
Public Sub Suspend ()
属性

例外

.NET Core と .NET 5 以降のみ: すべての場合。

スレッドが開始されていないか、または停止しています。

呼び出し元に適切な SecurityPermissionがありません。

注釈

スレッドが既に中断されている場合、このメソッドは無効です。

Caution

SuspendメソッドとResumeメソッドを使用してスレッドのアクティビティを同期しないでください。 スレッドを中断したときに実行されているコードを把握する方法はありません。 セキュリティアクセス許可の評価中にスレッドがロックを保持している間にスレッドを中断すると、 AppDomain 内の他のスレッドがブロックされる可能性があります。 クラス コンストラクターの実行中にスレッドを中断すると、そのクラスを使用しようとする AppDomain 内の他のスレッドがブロックされます。 デッドロックは非常に簡単に発生する可能性があります。

スレッドで Suspend メソッドを呼び出すと、スレッドの中断が要求されたことがシステムで確認され、スレッドが実際にスレッドを中断する前に安全なポイントに達するまでスレッドを実行できます。 スレッドのセーフ ポイントは、ガベージ コレクションを実行できる実行時のポイントです。 セーフ ポイントに達すると、ランタイムは、中断されたスレッドがマネージド コードでそれ以上進行しないことを保証します。 マネージド コードの外部で実行されているスレッドは、常にガベージ コレクションに対して安全であり、マネージド コードの実行を再開するまで実行が続行されます。

適用対象

こちらもご覧ください