コード例 #1
0
 // IsOneWay = true
 // Operations in progress don't block clients. They are executed asynchronously.
 //private async System.Threading.Tasks.Task buttonRequestReplyOperationAsync_ClickAsync(object sender, EventArgs e) // Wrong, not working - return type must be void for async event
 private async void buttonRequestReplyOperationAsync_ClickAsync(object sender, EventArgs e)
 {
     try
     {
         listBox1.Items.Add($"Request-Reply Operation Started @{DateTime.Now}");
         buttonRequestReplyOperation.Enabled = false;
         listBox1.Items.Add(await client.RequestReplyOperationAsync());
         buttonRequestReplyOperation.Enabled = true;
         listBox1.Items.Add($"Request-Reply Operation Completed @{DateTime.Now}");
         listBox1.Items.Add(string.Empty);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #2
0
        public async Task <ActionResult> RequestReplyOperationAsync()
        {
            string message;

            try
            {
                SampleServiceClient client = new SampleServiceClient();
                string processingTime      = await client.RequestReplyOperationAsync();

                message = $"Request-Reply Operation Completed @ {DateTime.Now} - {processingTime}";
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }


            return(PartialView("RequestReplyOperation", message));
        }