码迷,mamicode.com
首页 > 其他好文 > 详细

调用WCF的异步方法

时间:2015-06-03 09:40:49      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:

            AsyncCallback aLoginCallback = delegate(IAsyncResult result)
                                           {
                                               var aSystemUser = WcfClient.Instance.EndSystemUser_Login(result);
                                               result.AsyncWaitHandle.Close();

                                               if (string.IsNullOrWhiteSpace(aSystemUser.UserId))
                                               {
                                                   ShowMessageBoxInNonMainThread("登录失败:用户名称或者用户密码错误!");
                                                   return;
                                               }

                                               CommonCache.CurrentUser = aSystemUser;

                                               //SynchronizationContext和SendOrPostCallback的引入是为了解决不能在非主线程中访问主线程中创建的控件的问题
                                               SendOrPostCallback aSendOrPostCallback = delegate
                                                                                        {
                                                                                            Hide();
                                                                                            MainForm.Instance.ShowDialog();
                                                                                        };
                                               SynchronizationContext.Current.Send(aSendOrPostCallback, null);
                                           };

            var aParam = GetForm<SystemUserParameter>();
            WcfClient.Instance.BeginSystemUser_Login(aParam, aLoginCallback, null);

  

调用WCF的异步方法

标签:

原文地址:http://www.cnblogs.com/ningkyolei/p/4548286.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!