private async void RunBtnClick(object sender, RoutedEventArgs e) { try { statusLabel.Content = "Status: "; runBtn.IsEnabled = selectBtn.IsEnabled = pathTB.IsEnabled = false; if (!CheckFileExist(pathTB.Text)) { throw new Exception(); } if (encodeRadio.IsChecked.HasValue && encodeRadio.IsChecked.Value) { await _huffmanService.EncodeAsync(pathTB.Text, (int)Math.Floor(blockSizeSlider.Value)); } else if (decodeRadio.IsChecked.HasValue && decodeRadio.IsChecked.Value) { await _huffmanService.DecodeAsync(pathTB.Text); } statusLabel.Content = "Status: Ok"; } catch (Exception ex) { statusLabel.Content = "Status: Error"; MessageBox.Show(ex.ToString()); } finally { runBtn.IsEnabled = selectBtn.IsEnabled = pathTB.IsEnabled = true; } }