提問
如何避免任務重複執行
回答
public readonly SemaphoreSlim semaphore = new(1);
semaphore..Wait();
//do something
...
//做完了
semaphore.Release();
參考
https://learn.microsoft.com/zh-cn/dotnet/api/system.threading.semaphoreslim?view=net-6.0
如何避免任務重複執行
public readonly SemaphoreSlim semaphore = new(1);
semaphore..Wait();
//do something
...
//做完了
semaphore.Release();
https://learn.microsoft.com/zh-cn/dotnet/api/system.threading.semaphoreslim?view=net-6.0