Created
October 6, 2015 21:21
-
-
Save i3arnon/9c9748964573acda9a33 to your computer and use it in GitHub Desktop.
LogicalFlow - A wrapper over LogicalOperationStack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class LogicalFlow | |
{ | |
public static Guid CurrentOperationId | |
{ | |
get | |
{ | |
return Trace.CorrelationManager.LogicalOperationStack.Count > 0 | |
? (Guid) Trace.CorrelationManager.LogicalOperationStack.Peek() | |
: Guid.Empty; | |
} | |
} | |
public static IDisposable StartScope() | |
{ | |
Trace.CorrelationManager.StartLogicalOperation(); | |
return new Stopper(); | |
} | |
private static void StopScope() | |
{ | |
Trace.CorrelationManager.StopLogicalOperation(); | |
} | |
private class Stopper : IDisposable | |
{ | |
private bool _isDisposed; | |
public void Dispose() | |
{ | |
if (!_isDisposed) | |
{ | |
StopScope(); | |
_isDisposed = true; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment