信号量苗条等待优先级 [英] SemaphoreSlim Await Priority
问题描述
我想知道SemaphoreSlim
在调用Await时是否具有优先级.
I am wondering if SemaphoreSlim
has anything like a priority when calling Await.
我什么都找不到,但是也许有人以前做过类似的事情.
I have not been able to find anything, but maybe someone has done something like this before.
想法是,如果需要的话,可以稍后以更高的优先级在信号量上调用await,它将使await首先返回.
The idea is, that if I need to, an await can be called on the semaphore later on with a higher priority, and it will allow the await to return first.
推荐答案
否,SemaphoreSlim
中没有优先级,无论您使用的是同步锁定还是异步锁定.
No, there are no priorities in SemaphoreSlim
, whether you're using synchronous or asynchronous locking.
很少需要异步锁的优先级.通常,如果您退后一步,放眼大局,这些问题通常会提供更优雅的解决方案.
There is very rarely ever a need for priorities with asynchronous locks. Usually these kinds of problems have more elegant solutions if you take a step back and look at the bigger picture.
这篇关于信号量苗条等待优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!