Main Page | Class Hierarchy | Class List | File List | Class Members

Common/MessageQueue.cs

00001 using System;
00002 using System.Threading;
00003 using System.Collections;
00004 
00005 namespace Common
00006 {
00010         public class MessageQueue : Queue
00011         {
00013                 public MessageQueue() : base() {}
00014                 
00016                 public virtual Message DequeueBlocking() {
00017                         Message result;
00018                         lock (this) {
00019                                 while (Count == 0) {
00020                                         Monitor.Wait(this);
00021                                 }
00022                                 result = (Message)Dequeue();
00023                                 Monitor.Pulse(this);
00024                         }
00025                         return result;
00026                 }
00027 
00028                 public virtual void EnqueueBlocking(Message msg) {
00029                         lock(this) {
00030                                 base.Enqueue(msg);
00031                                 Monitor.Pulse(this);
00032                         }
00033                 }
00034         }
00035 }

Generated on Mon May 8 22:07:27 2006 by  doxygen 1.3.9.1