|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
Task, classe
Espace de noms : System.Threading.Tasks
Assembly : mscorlib (dans mscorlib.dll)
Le type Task expose les membres suivants.
| Nom | Description | |
|---|---|---|
![]() ![]() ![]() | Task(Action) | |
![]() ![]() ![]() | Task(Action, CancellationToken) | |
![]() ![]() ![]() | Task(Action, TaskCreationOptions) | |
![]() ![]() ![]() | Task(Action<Object>, Object) | |
![]() ![]() ![]() | Task(Action, CancellationToken, TaskCreationOptions) | |
![]() ![]() ![]() | Task(Action<Object>, Object, CancellationToken) | |
![]() ![]() ![]() | Task(Action<Object>, Object, TaskCreationOptions) | |
![]() ![]() ![]() | Task(Action<Object>, Object, CancellationToken, TaskCreationOptions) |
| Nom | Description | |
|---|---|---|
![]() ![]() ![]() | AsyncState | |
![]() ![]() ![]() | CreationOptions | |
![]() ![]() ![]() ![]() | CurrentId | |
![]() ![]() ![]() | Exception | |
![]() ![]() ![]() ![]() | Factory | |
![]() ![]() ![]() | Id | |
![]() ![]() ![]() | IsCanceled | |
![]() ![]() ![]() | IsCompleted | |
![]() ![]() ![]() | IsFaulted | |
![]() ![]() ![]() | Status |
| Nom | Description | |
|---|---|---|
![]() ![]() | ConfigureAwait | |
![]() ![]() ![]() | ContinueWith(Action<Task>) | |
![]() ![]() ![]() | ContinueWith(Action<Task>, CancellationToken) | |
![]() ![]() ![]() | ContinueWith(Action<Task>, TaskContinuationOptions) | |
![]() ![]() ![]() | ContinueWith(Action<Task>, TaskScheduler) | |
![]() ![]() | ContinueWith(Action<Task, Object>, Object) | |
![]() ![]() | ContinueWith(Action<Task, Object>, Object, CancellationToken) | |
![]() ![]() | ContinueWith(Action<Task, Object>, Object, TaskContinuationOptions) | |
![]() ![]() | ContinueWith(Action<Task, Object>, Object, TaskScheduler) | |
![]() ![]() ![]() | ContinueWith(Action<Task>, CancellationToken, TaskContinuationOptions, TaskScheduler) | |
![]() ![]() | ContinueWith(Action<Task, Object>, Object, CancellationToken, TaskContinuationOptions, TaskScheduler) | |
![]() ![]() ![]() | ContinueWith<TResult>(Func<Task, TResult>) | |
![]() ![]() ![]() | ContinueWith<TResult>(Func<Task, TResult>, CancellationToken) | |
![]() ![]() ![]() | ContinueWith<TResult>(Func<Task, TResult>, TaskContinuationOptions) | |
![]() ![]() ![]() | ContinueWith<TResult>(Func<Task, TResult>, TaskScheduler) | |
![]() ![]() | ContinueWith<TResult>(Func<Task, Object, TResult>, Object) | |
![]() ![]() | ContinueWith<TResult>(Func<Task, Object, TResult>, Object, CancellationToken) | |
![]() ![]() | ContinueWith<TResult>(Func<Task, Object, TResult>, Object, TaskContinuationOptions) | |
![]() ![]() | ContinueWith<TResult>(Func<Task, Object, TResult>, Object, TaskScheduler) | |
![]() ![]() ![]() | ContinueWith<TResult>(Func<Task, TResult>, CancellationToken, TaskContinuationOptions, TaskScheduler) | |
![]() ![]() | ContinueWith<TResult>(Func<Task, Object, TResult>, Object, CancellationToken, TaskContinuationOptions, TaskScheduler) | |
![]() ![]() ![]() | Delay(Int32) | |
![]() ![]() ![]() | Delay(TimeSpan) | |
![]() ![]() ![]() | Delay(Int32, CancellationToken) | |
![]() ![]() ![]() | Delay(TimeSpan, CancellationToken) | |
![]() | Dispose() | |
![]() | Dispose(Boolean) | |
![]() ![]() ![]() | Equals(Object) | |
![]() ![]() ![]() | Finalize | |
![]() ![]() ![]() | FromResult<TResult> | |
![]() ![]() | GetAwaiter | |
![]() ![]() ![]() | GetHashCode | |
![]() ![]() ![]() | GetType | |
![]() ![]() ![]() | MemberwiseClone | |
![]() ![]() ![]() | Run(Action) | |
![]() ![]() ![]() | Run(Func<Task>) | |
![]() ![]() ![]() | Run(Action, CancellationToken) | |
![]() ![]() ![]() | Run(Func<Task>, CancellationToken) | |
![]() ![]() ![]() | Run<TResult>(Func<Task<TResult>>) | |
![]() ![]() ![]() | Run<TResult>(Func<TResult>) | |
![]() ![]() ![]() | Run<TResult>(Func<Task<TResult>>, CancellationToken) | |
![]() ![]() ![]() | Run<TResult>(Func<TResult>, CancellationToken) | |
![]() ![]() ![]() | RunSynchronously() | |
![]() ![]() ![]() | RunSynchronously(TaskScheduler) | |
![]() ![]() ![]() | Start() | |
![]() ![]() ![]() | Start(TaskScheduler) | |
![]() ![]() ![]() | ToString | |
![]() ![]() ![]() | Wait() | |
![]() ![]() ![]() | Wait(CancellationToken) | |
![]() ![]() ![]() | Wait(Int32) | |
![]() ![]() ![]() | Wait(TimeSpan) | |
![]() ![]() ![]() | Wait(Int32, CancellationToken) | |
![]() ![]() ![]() ![]() | WaitAll(Task[]) | |
![]() ![]() ![]() ![]() | WaitAll(Task[], Int32) | |
![]() ![]() ![]() ![]() | WaitAll(Task[], CancellationToken) | |
![]() ![]() ![]() ![]() | WaitAll(Task[], TimeSpan) | |
![]() ![]() ![]() ![]() | WaitAll(Task[], Int32, CancellationToken) | |
![]() ![]() ![]() ![]() | WaitAny(Task[]) | |
![]() ![]() ![]() ![]() | WaitAny(Task[], Int32) | |
![]() ![]() ![]() ![]() | WaitAny(Task[], CancellationToken) | |
![]() ![]() ![]() ![]() | WaitAny(Task[], TimeSpan) | |
![]() ![]() ![]() ![]() | WaitAny(Task[], Int32, CancellationToken) | |
![]() ![]() ![]() | WhenAll(IEnumerable<Task>) | |
![]() ![]() ![]() | WhenAll(Task[]) | |
![]() ![]() ![]() | WhenAll<TResult>(IEnumerable<Task<TResult>>) | |
![]() ![]() ![]() | WhenAll<TResult>(Task<TResult>[]) | |
![]() ![]() ![]() | WhenAny(IEnumerable<Task>) | |
![]() ![]() ![]() | WhenAny(Task[]) | |
![]() ![]() ![]() | WhenAny<TResult>(IEnumerable<Task<TResult>>) | |
![]() ![]() ![]() | WhenAny<TResult>(Task<TResult>[]) | |
![]() ![]() ![]() | Yield |
| Nom | Description | |
|---|---|---|
![]() ![]() | AsAsyncAction | |
![]() | DispatcherOperationWait() | Surchargé. |
![]() | DispatcherOperationWait(TimeSpan) | Surchargé. |
![]() | IsDispatcherOperationTask |
| Nom | Description | |
|---|---|---|
![]() ![]() ![]() ![]() | IAsyncResult.AsyncWaitHandle | |
![]() ![]() ![]() ![]() | IAsyncResult.CompletedSynchronously |
// C# var t = Task.Factory.StartNew(() => DoAction()); ' Visual Basic Dim t = Task.Factory.StartNew(Function() DoAction())
Pour les développeurs de débogueur
Remarque |
|---|
L'attribut HostProtectionAttribute appliqué à ce type ou membre a la valeur de propriété Resources suivante : Synchronization | ExternalThreading. HostProtectionAttribute n'affecte pas les applications bureautiques (qui sont généralement démarrées en double-cliquant sur une icône, en tapant une commande ou en entrant une URL dans un navigateur). Pour plus d'informations, consultez la classe HostProtectionAttribute ou Attributs de programmation et de protection des hôtes SQL Server. |
using System; using System.Threading; using System.Threading.Tasks; class StartNewDemo { // Demonstrated features: // Task ctor() // Task.Factory // Task.Wait() // Task.RunSynchronously() // Expected results: // Task t1 (alpha) is created unstarted. // Task t2 (beta) is created started. // Task t1's (alpha) start is held until after t2 (beta) is started. // Both tasks t1 (alpha) and t2 (beta) are potentially executed on threads other than the main thread on multi-core machines. // Task t3 (gamma) is executed synchronously on the main thread. // Documentation: // http://msdn.microsoft.com/en-us/library/system.threading.tasks.task_members(VS.100).aspx static void Main() { Action<object> action = (object obj) => { Console.WriteLine("Task={0}, obj={1}, Thread={2}", Task.CurrentId, obj.ToString(), Thread.CurrentThread.ManagedThreadId); }; // Construct an unstarted task Task t1 = new Task(action, "alpha"); // Cosntruct a started task Task t2 = Task.Factory.StartNew(action, "beta"); // Block the main thread to demonstate that t2 is executing t2.Wait(); // Launch t1 t1.Start(); Console.WriteLine("t1 has been launched. (Main Thread={0})", Thread.CurrentThread.ManagedThreadId); // Wait for the task to finish. // You may optionally provide a timeout interval or a cancellation token // to mitigate situations when the task takes too long to finish. t1.Wait(); // Construct an unstarted task Task t3 = new Task(action, "gamma"); // Run it synchronously t3.RunSynchronously(); // Although the task was run synchrounously, it is a good practice to wait for it which observes for // exceptions potentially thrown by that task. t3.Wait(); } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.



