信号量苗条等待优先级

编程入门 行业动态 更新时间:2024-10-25 06:24:00
本文介绍了信号量苗条等待优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道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.

更多推荐

信号量苗条等待优先级

本文发布于:2023-10-09 06:25:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1474955.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:信号量   优先级   苗条

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!