first commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using Rougamo;
|
||||
using Rougamo.Context;
|
||||
using System.Threading;
|
||||
|
||||
namespace JSMachine.WMS.Infrastructure.Attributes
|
||||
{
|
||||
/// <summary>
|
||||
/// 注意,任何使用该标记的项目中均需要安装Rougamo.Fody包,否则属性标记锁将失效
|
||||
/// </summary>
|
||||
public class MethodLockedAttribute : MoAttribute
|
||||
{
|
||||
private static readonly SemaphoreSlim SemaphoreSlim = new(1);
|
||||
|
||||
public override void OnEntry(MethodContext context)
|
||||
{
|
||||
SemaphoreSlim.Wait();
|
||||
|
||||
}
|
||||
|
||||
public override void OnExit(MethodContext context)
|
||||
{
|
||||
SemaphoreSlim.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user