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 = SetControlEnabled;
16 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 = SetControlText;
34 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 = SetCheckboxChecked;
52 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 = SetCheckboxItemChecked;
70 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 = SetProgressValue;
88 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 = SetComboBoxItems;
106 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 = SetControlVisible;
126 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)
141 DisplayDialogCallback d = DisplayDialog;
144 Invoke(d, new object[] { control, modal });
146 catch (Exception) { }
151 control.ShowDialog(this);