More races all the good time of day There was such a problem (WPF). There is a click handler, it is executed, that is, it launches the file for installation, But if the user cancels the installation, the program hangs and throws an exception that the user canceled the action. What could be the matter please tell me.
private void InstallLBSelectCh(object sender, SelectionChangedEventArgs e) { System.Diagnostics.Process p = new System.Diagnostics.Process(); switch (InstallLB.SelectedIndex) { case 0: p.StartInfo.FileName = GetFiles[InstallLB.SelectedIndex]; p.Start(); break; case 1: p.StartInfo.FileName = GetFiles[InstallLB.SelectedIndex]; p.Start(); break; case 2: p.StartInfo.FileName = GetFiles[InstallLB.SelectedIndex]; p.Start(); break; default: goto case 0; } } So far I have found only such a solution.
private void InstallLBSelectCh(object sender, SelectionChangedEventArgs e) { Process p = new Process(); switch (InstallLB.SelectedIndex) { default: case 0: p.StartInfo.FileName = GetFiles[InstallLB.SelectedIndex]; try { p.Start(); } catch { MessageBox.Show("Canceled by User"); } break; case 1: p.StartInfo.FileName = GetFiles[InstallLB.SelectedIndex]; p.Start(); break; case 2: p.StartInfo.FileName = GetFiles[InstallLB.SelectedIndex]; p.Start(); break; } }
default: case0:, than throw over goto! - EvgeniyZ