【发布时间】:2011-12-02 13:24:02
【问题描述】:
有可能(以一种有意义的方式)吗?
例如,假设我想实现一个等待队列,如下所示:
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;
}
【问题讨论】:
-
如果可能的话,您想如何使用它?
-
不。我给出的例子恰好与一个关于队列的实际问题相吻合。
-
@the_ajp:我完全看不出这个问题与这个问题有什么关系。
标签: c# multithreading