首页 > 学院 > 开发设计 > 正文

调用WCF的异步方法

2019-11-17 02:20:12
字体:
来源:转载
供稿:网友

调用WCF的异步方法

            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);

  


发表评论 共有0条评论
用户名: 密码:
验证码: 匿名发表