在C#中的条件变量 [英] Condition variables in C#
本文介绍了在C#中的条件变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是条件变量和放大器;在C#中使用的显示器?
Are condition variables & monitors used in C#?
能有人给我一个例子吗?
Can someone give me an example?
推荐答案
您刚刚使用的.NET信号条件变量的等效是抽象类WaitHandle中。它的实际实现是和的ManualResetEvent的AutoResetEvent类。
The equivalent of a condition variable that you use just for signaling in .NET is the abstract WaitHandle class. Practical implementations of it are the ManualResetEvent and AutoResetEvent classes.
这是你作为显示器使用条件变量需要System.Threading.Monitor。 C#的锁定
语句使得它非常容易使用,它可以确保显示器始终没有明确地编程退出()调用退出。
A condition variable that you use as a monitor requires System.Threading.Monitor. The C# lock
statement makes it very easy to use, it ensures the monitor is always exited without explicitly programming the Exit() call.
这篇关于在C#中的条件变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文