ICallerContextServiceSpawnTaskTResult Method |
Creates an asynchronous task which runs with the current caller context.
Namespace: Dundas.BIAssembly: Dundas.BI.Core (in Dundas.BI.Core.dll) Version: 2.0.0.0 (26.2.0.1000)
SyntaxTask<TResult> SpawnTask<TResult>(
string name,
Func<TResult> func,
GroupCancellationToken? cancellationToken
)
Function SpawnTask(Of TResult) (
name As String,
func As Func(Of TResult),
cancellationToken As GroupCancellationToken
) As Task(Of TResult)
generic<typename TResult>
Task<TResult>^ SpawnTask(
String^ name,
Func<TResult>^ func,
GroupCancellationToken^ cancellationToken
)
abstract SpawnTask :
name : string *
func : Func<'TResult> *
cancellationToken : GroupCancellationToken -> Task<'TResult> Parameters
- name String
- A name which will be assigned to the spawned operation (used for diagnostic purposes).
- func FuncTResult
- The function to invoke asynchronously.
- cancellationToken GroupCancellationToken
- The cancellation token.
Type Parameters
- TResult
- The type of object returned by the task.
Return Value
TaskTResultA task object representing the asynchronous operation.
Exceptions
Remarks
The spawned task will have the same caller context as the code which called this method. Therefore, if the caller context
of the calling method is disposed before the body of the spawned task has completed, the task may lose its caller context during execution.
If you want to ensure that the caller context remains valid for the entire duration of the spawned task, because the task may outlive
the calling method's context, use
QueueBackgroundTask(Action, TimeSpan, CancellationToken).
See Also