コード例 #1
0
ファイル: Program.cs プロジェクト: rockhe168/PracticeCode
        static void Main(string[] args)
        {
            Request request = new Request()
            {
                Id = 1,
                Name = "Rock",
                Address = "携程"
            };

            Response response = new Response();

            TempOrder tmpOrder = new TempOrder();

            List<LogicException> exception = new List<LogicException>();


            try
            {
                DoWorking canBooking = new DoWorking(tmpOrder.CanBooking);

                IAsyncResult canBookingResult = canBooking.BeginInvoke(request, response, new AsyncCallback(CallBackFunction), null);

                DoWorking saveOrder = new DoWorking(SaveOrder);

                IAsyncResult saveOrderResult = saveOrder.BeginInvoke(request, response, new AsyncCallback(CallBackFunction), null);

                DoWorking paymentInfo = new DoWorking(tmpOrder.GetPaymentInfo);

                IAsyncResult paymentInfoResult = paymentInfo.BeginInvoke(request, response, new AsyncCallback(CallBackFunction), null);


                bool result = true;
                int count = 0;
                while (result && count < 100000)
                {
                    count++;
                    if (canBookingResult.IsCompleted && saveOrderResult.IsCompleted && paymentInfoResult.IsCompleted)
                    {
                        Console.WriteLine("全部完成.....");
                        result = false;
                    }
                    else
                    {
                        Console.WriteLine("还没有全部完成....");
                        result = true;
                    }
                }

                //canBookingResult.

                Console.WriteLine(response.ToString());
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine("处理异常了,,"+ex.Message);
                Console.ReadKey();
                //throw;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: rockhe168/PracticeCode
 public static void SaveOrder(Request request, Response response)
 {
     response.Name = request.Name;
     Thread.Sleep(500);
     Console.WriteLine("SaveOrder Woking....");
     request.HaveException();
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: rockhe168/PracticeCode
 public void GetPaymentInfo(Request request, Response response)
 {
     Console.WriteLine("GetPaymentInfo Woking....");
     response.Address = request.Address;
     Thread.Sleep(200);
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: rockhe168/PracticeCode
        public void CanBooking(Request request, Response response)
        {
            Console.WriteLine("CanBooking Woking....");
            response.Id = request.Id;
            Thread.Sleep(200);

        }