2 using System.Windows.Forms;
6 public class AsyncForm : Form
8 delegate void SetControlEnabledCallback(Control control, bool val);
9 public void SetControlEnabled(Control control, bool val)
11 if (control.InvokeRequired)
13 SetControlEnabledCallback d = new SetControlEnabledCallback(SetControlEnabled);
16 this.Invoke(d, new object[] { control, val });
22 control.Enabled = val;
26 delegate void SetControlTextCallback(Control control, string val);
27 public void SetControlText(Control control, string val)
29 if (control.InvokeRequired)
31 SetControlTextCallback d = new SetControlTextCallback(SetControlText);
34 this.Invoke(d, new object[] { control, val });
44 delegate void SetCheckboxCheckedCallback(CheckBox control, bool val);
45 public void SetCheckboxChecked(CheckBox control, bool val)
47 if (control.InvokeRequired)
49 SetCheckboxCheckedCallback d = new SetCheckboxCheckedCallback(SetCheckboxChecked);
52 this.Invoke(d, new object[] { control, val });
58 control.Checked = val;
62 delegate void SetCheckboxItemCheckedCallback(CheckedListBox control, int index, bool val);
63 public void SetCheckboxItemChecked(CheckedListBox control, int index, bool val)
65 if (control.InvokeRequired)
67 SetCheckboxItemCheckedCallback d = new SetCheckboxItemCheckedCallback(SetCheckboxItemChecked);
70 this.Invoke(d, new object[] { control, index, val });
76 control.SetItemChecked(index, val);
80 delegate void SetProgressValueCallback(ProgressBar control, int val);
81 public void SetProgressValue(ProgressBar control, int val)
83 if (control.InvokeRequired)
85 SetProgressValueCallback d = new SetProgressValueCallback(SetProgressValue);
88 this.Invoke(d, new object[] { control, val });
98 delegate void SetComboBoxItemsCallback(ComboBox control, string selectedText, object[] val);
99 public void SetComboBoxItems(ComboBox control, string selectedText, object[] val)
101 if (control.InvokeRequired)
103 SetComboBoxItemsCallback d = new SetComboBoxItemsCallback(SetComboBoxItems);
106 this.Invoke(d, new object[] { control, selectedText, val });
108 catch (Exception) { }
112 control.Items.Clear();
113 control.Items.AddRange(val);
114 control.Text = selectedText;
118 delegate void SetControlVisibleCallback(Control control, bool val);
119 public void SetControlVisible(Control control, bool val)
121 if (control.InvokeRequired)
123 SetControlVisibleCallback d = new SetControlVisibleCallback(SetControlVisible);
126 this.Invoke(d, new object[] { control, val });
128 catch (Exception) { }
132 control.Visible = val;
136 delegate void DisplayDialogCallback(Form control, bool modal);
137 public void DisplayDialog(Form control, bool modal)
139 if (this.InvokeRequired)
141 DisplayDialogCallback d = new DisplayDialogCallback(DisplayDialog);
144 this.Invoke(d, new object[] { control, modal });
146 catch (Exception) { }
151 control.ShowDialog(this);