线程优先级
我得到了一个 System.Threading.Timer,我将其更改为较低优先级 (Thread.CurrentThread.Priority = XXXX)。
在退出回调方法之前我是否必须重置优先级,或者 .Net 在线程返回时是否会重置优先级?
I got a System.Threading.Timer
which I change to lower priority (Thread.CurrentThread.Priority = XXXX
).
Do I have to reset the priority before I exit the callback method, or will .Net reset the priority when it get's the thread back?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
System.Threading.Timer
使用ThreadPool
,不建议更改这些线程的优先级:为什么*不*更改 ThreadPool(或任务)线程的优先级? 而且它看起来不像线程池将优先级更改回来。所以看起来你一开始就不应该这样做,但如果你这样做了,你应该自己把它改回来。System.Threading.Timer
utilizes theThreadPool
and changing priorities for those is not recommended: Why *not* change the priority of a ThreadPool (or Task) thread? and it doesn't look like the thread pool changes the priority back. So it seems like you shouldn't do it in the first place but if you do it then you should change it back yourself.