mirror of https://github.com/abpframework/abp.git
4 changed files with 39 additions and 12 deletions
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using System.Threading; |
|||
|
|||
namespace Volo.Abp.Threading |
|||
{ |
|||
public static class AsyncLocalSimpleScopeExtensions |
|||
{ |
|||
public static IDisposable SetScoped<T>(this AsyncLocal<T> asyncLocal, T value) |
|||
{ |
|||
var previousValue = asyncLocal.Value; |
|||
asyncLocal.Value = value; |
|||
return new DisposeAction(() => |
|||
{ |
|||
asyncLocal.Value = previousValue; |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue