void button_ConnectedChanged(object sender, ConnectedChangedEventArgs e) { if (closing) return; Action action = () => { SetNotifyIcon(); }; if (this.InvokeRequired) { this.BeginInvoke(action); } else { action(); } }
void button_ConnectedChanged(object sender, ConnectedChangedEventArgs e) { if (closing) return; Action action = () => { notifyIcon1.Icon = e.IsConnected ? icons.icoGreen : icons.icoGrey; }; if (this.InvokeRequired) { this.BeginInvoke(action); } else { action(); } }