26 lines
639 B
C#
26 lines
639 B
C#
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();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|