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 void Enqueue(string queueName, string serItem) { QueueItem item = QueueItem.Deserialize(serItem); if (item != null) { McQueue Q = QueueManager[queueName]; if (Q == null) { return; } Q.Enqueue(item as IQueueItem); } }