Compartir a través de


ThreadingTools.WithCancellation<T> Method (Task<T>, CancellationToken)

Namespace:  Microsoft.VisualStudio.Threading
Assembly:  Microsoft.VisualStudio.Threading (in Microsoft.VisualStudio.Threading.dll)

Syntax

'Declaration
<ExtensionAttribute> _
Public Shared Function WithCancellation(Of T) ( _
    task As Task(Of T), _
    cancellationToken As CancellationToken _
) As Task(Of T)
public static Task<T> WithCancellation<T>(
    this Task<T> task,
    CancellationToken cancellationToken
)
[ExtensionAttribute]
public:
generic<typename T>
static Task<T>^ WithCancellation(
    Task<T>^ task, 
    CancellationToken cancellationToken
)
static member WithCancellation : 
        task:Task<'T> * 
        cancellationToken:CancellationToken -> Task<'T> 
JScript does not support generic types or methods.

Type Parameters

  • T

Parameters

Return Value

Type: System.Threading.Tasks.Task<T>

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Task<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

.NET Framework Security

See Also

Reference

ThreadingTools Class

WithCancellation Overload

Microsoft.VisualStudio.Threading Namespace