Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
TraceBeginEndAsync(TResult) Method (ITraceWriter, , String, TraceLevel, String, String, Action(TraceRecord), Func(Task(TResult)), Action(TraceRecord, TResult), Action(TraceRecord))

ITraceWriterExtensions.TraceBeginEndAsync(Of TResult) Method (ITraceWriter, , String, TraceLevel, String, String, Action(Of TraceRecord), Func(Of Task(Of TResult)), Action(Of TraceRecord, TResult), Action(Of TraceRecord))

Traces both a begin and an end trace around a specified operation.

Namespace:  System.Web.Http.Tracing
Assembly:  System.Web.Http (in System.Web.Http.dll)

<ExtensionAttribute> _
Public Shared Function TraceBeginEndAsync(Of TResult) ( _
	traceWriter As ITraceWriter, _
	request As HttpRequestMessage, _
	category As String, _
	level As TraceLevel, _
	operatorName As String, _
	operationName As String, _
	beginTrace As Action(Of TraceRecord), _
	execute As Func(Of Task(Of TResult)), _
	endTrace As Action(Of TraceRecord, TResult), _
	errorTrace As Action(Of TraceRecord) _
) As Task(Of TResult)
Dim traceWriter As ITraceWriter 
Dim request As HttpRequestMessage 
Dim category As String 
Dim level As TraceLevel 
Dim operatorName As String 
Dim operationName As String 
Dim beginTrace As Action(Of TraceRecord)
Dim execute As Func(Of Task(Of TResult))
Dim endTrace As Action(Of TraceRecord, TResult)
Dim errorTrace As Action(Of TraceRecord)
Dim returnValue As Task(Of TResult)

returnValue = traceWriter.TraceBeginEndAsync(request, _
	category, level, operatorName, operationName, _
	beginTrace, execute, endTrace, errorTrace)

Type Parameters


The type of result produced by the Task.


Type: System.Web.Http.Tracing.ITraceWriter

The ITraceWriter.

Type: HttpRequestMessage

The HttpRequestMessage with which to associate the trace. It may be null.

Type: System.String

The logical category of the trace.

Type: System.Web.Http.Tracing.TraceLevel

The TraceLevel of the trace.

Type: System.String

The name of the object performing the operation. It may be null.

Type: System.String

The name of the operation being performed. It may be null.

Type: System.Action(Of TraceRecord)

The Action to invoke prior to performing the operation, allowing the given TraceRecord to be filled in. It may be null.

Type: System.Func(Of Task(Of TResult))

An <see cref="T:System.Func`1" /> that returns the Task that will perform the operation.

Type: System.Action(Of TraceRecord, TResult)

The Action to invoke after successfully performing the operation, allowing the given TraceRecord to be filled in. The result of the completed task will also be passed to this action. This action may be null.

Type: System.Action(Of TraceRecord)

The Action to invoke if an error was encountered performing the operation, allowing the given TraceRecord to be filled in. It may be null.

Return Value

Type: System.Threading.Tasks.Task(Of TResult)
The Task returned by the operation.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ITraceWriter. When you use instance method syntax to call this method, omit the first parameter. For more information, see https://msdn.microsoft.com/en-us/library/bb384936(v=vs.108).aspx or https://msdn.microsoft.com/en-us/library/bb383977(v=vs.108).aspx.

The end trace will occur when the asynchronous operation completes, either success or failure.

© 2015 Microsoft