diff options
Diffstat (limited to 'src/System.Private.CoreLib/shared/Internal/Threading/Tasks/AsyncCausalitySupport.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/Internal/Threading/Tasks/AsyncCausalitySupport.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/Internal/Threading/Tasks/AsyncCausalitySupport.cs b/src/System.Private.CoreLib/shared/Internal/Threading/Tasks/AsyncCausalitySupport.cs new file mode 100644 index 0000000000..35f4dfe18c --- /dev/null +++ b/src/System.Private.CoreLib/shared/Internal/Threading/Tasks/AsyncCausalitySupport.cs @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Threading.Tasks; +using System.Runtime.CompilerServices; + +namespace Internal.Threading.Tasks +{ + // + // An internal contract that exposes just enough async debugger support needed by the AsTask() extension methods in the WindowsRuntimeSystemExtensions class. + // + public static class AsyncCausalitySupport + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void AddToActiveTasks(Task task) + { + if (Task.s_asyncDebuggingEnabled) + Task.AddToActiveTasks(task); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void RemoveFromActiveTasks(Task task) + { + if (Task.s_asyncDebuggingEnabled) + Task.RemoveFromActiveTasks(task.Id); + } + + public static bool LoggingOn + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + return AsyncCausalityTracer.LoggingOn; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void TraceOperationCreation(Task task, string operationName) + { + AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, task.Id, operationName, 0); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void TraceOperationCompletedSuccess(Task task) + { + AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, task.Id, AsyncCausalityStatus.Completed); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void TraceOperationCompletedError(Task task) + { + AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, task.Id, AsyncCausalityStatus.Error); + } + } +} + |