コード例 #1
0
        private void InvokeServiceAsync(int delay)
        {
            this.Trace.Write(string.Format("Calling service on thread {0}", Thread.CurrentThread.ManagedThreadId));

            var proxy = new TestServiceClient();

            proxy.DoWorkCompleted += (o, args) =>
            {
                if (!args.Cancelled)
                {
                    this.Trace.Write(string.Format("Completed calling service on thread {0} delay {1}", Thread.CurrentThread.ManagedThreadId, args.Result));
                    this.labelDelay.Text = args.Result.ToString();
                }
            };

            proxy.DoWorkAsync(delay);
        }