是否有可能(以有意義的方式)?如何繼承WaitHandle?
例如,假設我想實現一個可等待隊列如下:
public class WaitableQueue : WaitHandle {
public WaitableQueue() {
q = new Queue();
}
public void Enqueue(Object Arg) {
lock(this) {
q.Enqueue(Arg);
// set the waithandle here (how?)
}
}
public Type Dequeue() {
lock(this) {
if(q.Count == 1)
// reset the waithandle here (how?)
return q.Dequeue();
}
}
Queue q;
}
如果可能的話,你是如何使用它的? –
[C#中的隊列和等待句柄]的可能重複(http://stackoverflow.com/questions/2741042/queues-and-wait-handles-in-c-sharp) –
不可以。我給出的例子恰好與關於隊列的實際問題相吻合。 – schwrz