Created
January 7, 2018 22:03
-
-
Save Im5tu/40dfcbc80e12902ed3af6d3b8d8c8ced to your computer and use it in GitHub Desktop.
DisposeCorrelation
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
private class DisposeCorrelation : IDisposable | |
{ | |
private readonly AsyncLocal<Stack<Guid>> _localStack; | |
public DisposeCorrelation(AsyncLocal<Stack<Guid>> localStack) | |
{ | |
_localStack = localStack; | |
} | |
public void Dispose() | |
{ | |
var stack = _localStack.Value ?? new Stack<Guid>(); | |
if(stack.Count > 0) | |
stack.Pop(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment