因此使用lock將單一Thread鎖住會導致出現 'Cannot await in the body of a lock statement'的錯誤
將Lock物件改成使用SemaphoreSlim,於function起始與結束加入WaitAsync與Release即可達到Lock的效果。
SemaphoreSlim完整介紹 : 用 SemaphoreSlim 來做 async/await 的鎖定
使用如下圖↓

*Nickname: | |
E-mail: | |
Blog URL: | |
#Nickname#
2023/3/23 下午 03:00:41
#CommentContent#
|
|
*請輸入驗證碼: | |