public void putQ(object o) { lock (this) { //if(m_stopping) //return; // Put an item on the queue. If there are any receivers waiting // dispatch the item immediately. Otherwise add to the queue if (m_wait_queue.Count > 0) { // pop off the first waiter from the wait queue // and dispatch the item AsyncWork op = (AsyncWork)m_wait_queue.Dequeue(); // plug the item into the operation and post the lot // to the threadpool ThreadPool.QueueUserWorkItem(op.m_waitCallback, o); } else { m_item_queue.Enqueue(o); } } }
public void getQ(AsyncWork op) { lock (this) { //if(m_stopping) //return; // Retrieve an item from the queue, to avoid sequencing // problems the item has to go through the completion port if (m_item_queue.Count > 0) { // pop off the first item from the item queue // and dispatch the item object o = m_item_queue.Dequeue(); // plug the item into the operation and post the lot // to the threadpool ThreadPool.QueueUserWorkItem(op.m_waitCallback, o); } else { m_wait_queue.Enqueue(op); } } }
public DefaultServiceHandler() { // // TODO: Add constructor logic here // m_async_receive = new AsyncReceive(); m_async_send = new AsyncSend(); m_async_init = new AsyncSend(); m_event_queue = new EventQueue(); m_async_work = new AsyncWork(); }
public override void handle_work(AsyncWork ar) { byte [] buffer = (byte [])ar.item(); // Craete a new timer and send the buffer //AsyncTimer t = new AsyncTimer(); //t.open(this, 0); //t.work(1, buffer); // start a new work m_async_send.send(buffer); //m_async_work.work(); m_event_queue.getQ(ar); }
public virtual void handle_work(AsyncWork ar) { }