的AutoResetEvent,ManualResetEvent的VS监视器 [英] AutoResetEvent, ManualResetEvent vs Monitor
问题描述
可以说我有来编排在.NET 3.5 SP1同步算法和任何在标题中所列的同步原语的伏贴的任务。
Lets say I have to orchestrate a synchronization algorithm in .Net 3.5 SP1 and any of the synchronization primitives listed in the title fit perfectly for the task.
从性能的角度来看,这是比其他人更高性能的任意单个的?
From a performance perspective, is any single one of those more performant than the others?
我问这个,因为我一直在编码有一段时间了,但没有关于这个问题的正确知识。
I ask this because I have been coding for a while now, but without proper knowledge on the subject.
推荐答案
如果可以的话,去与监控。它类似于一个CRITICAL_SECTION。的AutoResetEvent / ManualResetEvent的可能具有稍微更多的开销,因为这些都可以通过不同的方法来共享,而监视器属于一个过程
If you can, go with Monitor. It's similar to a CRITICAL_SECTION. AutoResetEvent/ManualResetEvent might have slightly more overhead, since these can be shared by different processes, whereas a Monitor belongs to a single process.
这篇关于的AutoResetEvent,ManualResetEvent的VS监视器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!