private async void RefreshCaptcha() { await DialogHost.Show(new BusyProgressView(), async (object s, DialogOpenedEventArgs e) => { var captchaResult = await _loginController.GetCaptcha(); if (captchaResult.ResultStatus == ResultType.ConnectionProblem) { Error = "خطا در اتصال"; } else { BitmapImage bitmap = null; try { using (WebClient webClient = new WebClient()) { var response = await webClient.DownloadDataTaskAsync(new Uri(captchaResult.Content)); using (var stream = new MemoryStream(response)) { bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.StreamSource = stream; bitmap.EndInit(); bitmap.Freeze(); CaptchaImage = bitmap; } } } catch (Exception) { Error = "خطا در اتصال"; } } e.Session.Close(); }); }