static void Main(string[] args) { Console.WriteLine("Remote host: "); string host = Console.ReadLine(); CConnectionContext cc = new CConnectionContext(host, 20901, "async_queue_client", "pwd_for_async_queue"); using (CSocketPool <CAsyncQueue> spAq = new CSocketPool <CAsyncQueue>()) { if (!spAq.StartSocketPool(cc, 1, 1)) { Console.WriteLine("Failed in connecting to remote async queue server"); Console.WriteLine("Press any key to close the application ......"); Console.Read(); return; } CAsyncQueue aq = spAq.Seek(); //Optionally, you can enqueue messages with transaction style by calling the methods StartQueueTrans and EndQueueTrans in pair aq.StartQueueTrans(TEST_QUEUE_KEY, (errCode) => { //error code could be one of CAsyncQueue.QUEUE_OK, CAsyncQueue.QUEUE_TRANS_ALREADY_STARTED, ...... }); TestEnqueue(aq); //test message batching using (CScopeUQueue sb = new CScopeUQueue()) { CUQueue q = sb.UQueue; CAsyncQueue.BatchMessage(idMessage3, "Hello", "World", q); CAsyncQueue.BatchMessage(idMessage4, true, 234.456, "MyTestWhatever", q); aq.EnqueueBatch(TEST_QUEUE_KEY, q, (res) => { System.Diagnostics.Debug.Assert(res == 2); }); } aq.EndQueueTrans(false); TestDequeue(aq); aq.WaitAll(); //get a queue key two parameters, message count and queue file size by default option oMemoryCached aq.FlushQueue(TEST_QUEUE_KEY, (messageCount, fileSize) => { Console.WriteLine("Total message count={0}, queue file size={1}", messageCount, fileSize); }); aq.GetKeys((keys) => { keys = null; }); aq.CloseQueue(TEST_QUEUE_KEY, (errCode) => { //error code could be one of CAsyncQueue.QUEUE_OK, CAsyncQueue.QUEUE_TRANS_ALREADY_STARTED, ...... }); Console.WriteLine("Press any key to close the application ......"); Console.Read(); } }