/// <summary> /// 设置验证码图片 /// </summary> private void SetVerifyCodeImage() { //AsyncHandler.CallFuncWithUI(System.Windows.Application.Current.Dispatcher, // () => // { App.Current.Dispatcher.Invoke((Action)(() => { var errMessage = string.Empty; var errCode = 0; HttpWebRequest request = null; HttpWebResponse ress = null; Stream sstreamRes = null; try { request = (HttpWebRequest)WebRequest.Create(AntSdkService.GetVerifyCodeImage(string.IsNullOrEmpty(this.LoginID) ? _selectedData : this.LoginID, ref errCode, ref errMessage)); request.Method = "GET"; ress = (HttpWebResponse)request.GetResponse(); sstreamRes = ress.GetResponseStream(); var bmp = new BitmapImage(); bmp.BeginInit(); //bmp.CacheOption = BitmapCacheOption.OnLoad; bmp.StreamSource = sstreamRes; bmp.EndInit(); Thread.Sleep(50); IdentifyingCodeBitmap = bmp; //if (sstreamRes != null) // return sstreamRes; } catch (System.Net.WebException x) { } finally { request.Abort(); ress?.Close(); sstreamRes?.Close(); } })); //return null; //}, //(ex, datas) => //{ // if (datas == null) return; //var bmp = new BitmapImage(); //bmp.BeginInit(); ////bmp.CacheOption = BitmapCacheOption.OnLoad; //bmp.StreamSource = sstreamRes; //bmp.EndInit(); //IdentifyingCodeBitmap = bmp; //}); //IdentifyingCodeBitmap = AntSdkService.GetVerifyCodeImage(string.IsNullOrEmpty(this.LoginID) ? _selectedData : this.LoginID, ref errCode, ref errMessage); }