Thread.Suspend Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Attenzione
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
Attenzione
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
Sospende il thread o se il thread è già sospeso, non ha alcun effetto.
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 ()
- Attributi
Eccezioni
Solo .NET Core e .NET 5+: in tutti i casi.
Il thread non è stato avviato o è inattivo.
Il chiamante non dispone dell'oggetto appropriato SecurityPermission.
Commenti
Se il thread è già sospeso, questo metodo non ha alcun effetto.
Caution
Non usare i Suspend metodi e Resume per sincronizzare le attività dei thread. Non è possibile sapere quale codice viene eseguito da un thread quando viene sospeso. Se si sospende un thread mentre contiene blocchi durante una valutazione delle autorizzazioni di sicurezza, altri thread in AppDomain potrebbero essere bloccati. Se si sospende un thread durante l'esecuzione di un costruttore di classe, vengono bloccati altri thread nel AppDomain tentativo di usare tale classe. I deadlock possono verificarsi molto facilmente.
Quando si chiama il Suspend metodo su un thread, il sistema rileva che è stata richiesta una sospensione del thread e consente l'esecuzione del thread fino a quando non raggiunge un punto sicuro prima di sospendere effettivamente il thread. Un punto sicuro per un thread è un punto di esecuzione in cui è possibile eseguire Garbage Collection. Una volta raggiunto un punto sicuro, il runtime garantisce che il thread sospeso non progredisca ulteriormente nel codice gestito. Un thread in esecuzione all'esterno del codice gestito è sempre sicuro per l'operazione di Garbage Collection e l'esecuzione continua fino a quando non tenta di riprendere l'esecuzione del codice gestito.