相关疑难解决方法(0)

我怎样才能将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;
  }
Run Code Online (Sandbox Code Playgroud)

c# multithreading

1
推荐指数
1
解决办法
978
查看次数

标签 统计

c# ×1

multithreading ×1