Skip to content

Instantly share code, notes, and snippets.

@i3arnon
Created October 6, 2015 21:21
Show Gist options
  • Save i3arnon/9c9748964573acda9a33 to your computer and use it in GitHub Desktop.
Save i3arnon/9c9748964573acda9a33 to your computer and use it in GitHub Desktop.
LogicalFlow - A wrapper over LogicalOperationStack
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