嗨我想在我的应用程序中使用信号量。我已经这样声明。在c中使用信号量#
using System;
using System.Threading;
// This thread allows only two instances of itself
// to run at any one time.
class MyThread {
public Thread Thrd;
static Semaphore sem = new Semaphore(2, 2);
public MyThread(string name) {
Thrd = new Thread(this.Run);
Thrd.Name = name;
Thrd.Start();
}
但我不能够编译它给我这个错误
The type or namespace name 'Semaphore' could not be found
(are you missing a using directive or an assembly reference?)
但我已经添加了命名空间using System.Threading;
我能够使用互斥。 可能是我错过了什么。还有其他需要添加的参考。?我正在使用VS 2010。框架4.0
It在'System.dll'中定义,显然他正在使用它。他还提到它是.NET框架4. – oleksii 2013-03-27 12:10:18
@oleksii:不一定。 http://social.msdn.microsoft.com/Forums/en-US/netfxsetup/thread/545b1628-23fb-4d69-ab42-09ed008e3b46/ 和System.Threading.dll被添加到.NET 4.0中 – 2013-03-27 12:10:39
我已添加参考'系统'现在再次工作 – Rakesh 2013-03-27 12:17:38