private static void RunAsyncQueue() { DateTime start = DateTime.Now; McQueueProperties prop = new McQueueProperties(qnmae); //prop.ConnectionString = cnn; prop.CoverMode = CoverMode.FileSystem;//.ItemsAndLog; prop.Server = 0; //prop.Provider = QueueProvider.SqlServer; prop.IsTrans = true; McQueue queue = McQueue.Create(prop); //queue.ReceiveCompleted += new ReceiveCompletedEventHandler(q_DequeueCompleted); IQueueItem[] items = CreateItems(3, queue); int count = queue.Count; Console.WriteLine("start enqueue"); //CreateItems(10,queue); count = queue.Count; int index = 0; Console.WriteLine("count:{0}", count); queue.Enqueue(items[0]); queue.Enqueue(items[1]); queue.Enqueue(items[2]); //IQueueItem item= queue.Dequeue(); //queue.CommitTrans(item); while (true)//index < count) { queue.BeginReceive(null); //queue.BeginReceive(TimeSpan.FromSeconds(10.0), 0, // new AsyncCallback(MsgReceiveCompleted)); index++; Thread.Sleep(10); } TimeSpan ts = DateTime.Now.Subtract(start); Console.WriteLine("took:{0}", ts.TotalSeconds); //signal.WaitOne(); }
public static void RunAsyncQueue() { DateTime start = DateTime.Now; QueueClient client = new QueueClient(); McQueueProperties prop = new McQueueProperties(qnmae); //prop.ConnectionString = cnn; //prop.CoverMode = CoverMode.ItemsAndLog; //prop.Server = 0; //prop.Provider = QueueProvider.SqlServer; //prop.IsTrans = true; queue = McQueue.Create(prop); //queue.ReceiveCompleted += new ReceiveCompletedEventHandler(q_DequeueCompleted); Console.WriteLine("start enqueue"); QueueInserter.InsertItems(100, queue); int count = queue.Count; Console.WriteLine("count:{0}", count); QueueListner(); int index = 0; while (true)//index < count) { queue.BeginReceive(null); //queue.BeginReceive(TimeSpan.FromSeconds(10.0), 0, // new AsyncCallback(MsgReceiveCompleted)); index++; Thread.Sleep(10); } TimeSpan ts = DateTime.Now.Subtract(start); Console.WriteLine("took:{0}", ts.TotalSeconds); //signal.WaitOne(); }