public BusyDialog(string message, ProcessingHandler handler, object parameter) { InitializeComponent(); lblMessage.Text = message; _handler = handler; _parameter = parameter; if (_icons == null) { _icons = new Bitmap[8]; for (int i = 0; i < _icons.Length; i++) { _icons[i] = Resources.ResourceManager.GetIcon("busy_blue-circle_" + (i + 1) + ".ico").ToBitmap(); } } }
public static object Show(string message, ProcessingHandler handler, object parameter) { object resultToReturn = null; BusyDialog dialog = new BusyDialog(message, handler, parameter); try { dialog.ShowDialog(); resultToReturn = dialog.Result; if (dialog.ExceptionThrown != null) { // Re-throw the same type of exception ConstructorInfo constructor = dialog.ExceptionThrown.GetType().GetConstructor(new Type[] { dialog.ExceptionThrown.GetType() }); if (constructor != null) { // Copy constructor throw (Exception)constructor.Invoke(new object[] { dialog.ExceptionThrown }); } else { constructor = dialog.ExceptionThrown.GetType().GetConstructor(new Type[] { typeof(string), typeof(Exception) }); if (constructor == null) { // default constructor throw new AGSEditorException(dialog.ExceptionThrown.Message, dialog.ExceptionThrown); } else { throw (Exception)constructor.Invoke(new object[] { dialog.ExceptionThrown.Message, dialog.ExceptionThrown }); } } } } finally { dialog.Dispose(); } return(resultToReturn); }
public static object Show(string message, ProcessingHandler handler, object parameter) { object resultToReturn = null; BusyDialog dialog = new BusyDialog(message, handler, parameter); try { dialog.ShowDialog(); resultToReturn = dialog.Result; if (dialog.ExceptionThrown != null) { // Re-throw the same type of exception ConstructorInfo constructor = dialog.ExceptionThrown.GetType().GetConstructor(new Type[] { dialog.ExceptionThrown.GetType() }); if (constructor != null) { // Copy constructor throw (Exception)constructor.Invoke(new object[] { dialog.ExceptionThrown }); } else { constructor = dialog.ExceptionThrown.GetType().GetConstructor(new Type[] { typeof(string), typeof(Exception) }); if (constructor == null) { // default constructor throw new AGSEditorException(dialog.ExceptionThrown.Message, dialog.ExceptionThrown); } else { throw (Exception)constructor.Invoke(new object[] { dialog.ExceptionThrown.Message, dialog.ExceptionThrown }); } } } } finally { dialog.Dispose(); } return resultToReturn; }