さまざまなコントロールを有効/無効にするマルチスレッド プログラムのデリゲートを作成する必要があります。すべてのコントロールに対して 1 つのハンドラーを使用することが最良の選択であることは論理的に思えますが、これが .net で可能かどうか、また可能であれば実装方法もわかりません。
1 に答える
1
public void SetControlsEnabled(bool enabled)
{
// Make sure we're in the correct thread
if (InvokeRequired)
{
// If not, run the method on the UI thread
Invoke(new MethodInvoker(() => SetControlsEnabled(enabled)));
return;
}
// Put all control code here, e.g:
// control1.Enabled = enabled;
// control2.Enabled = enabled;
// Alternatively, do a foreach(Control c in Controls) { ... }
}
于 2009-10-18T15:34:48.963 に答える