public DialogResult ThreadSafeWay(object msg, object form) { FormDelegate method = new FormDelegate(this.ThreadSafeWay); if (this.InvokeRequired) { return((DialogResult)this.Invoke(method, new object[] { msg, form })); } return((form as Form).ShowDialog(this)); }
public EvolveForm() { InitializeComponent(); this.world = new World(20, 20, this.foodlevel, this.populationsize, 400); this.fieldControl1.World = world; this.fieldControl1.DrawWorld(); this.redrawdelegate = this.DrawField; this.populationdelegate = this.ShowPopulationList; }
private void FocusWindow() { if (this.InvokeRequired) { FormDelegate d = new FormDelegate(FocusWindow); this.Invoke(d, new Object[] { }); } else { this.Activate(); } }
public Form1() { InitializeComponent(); _helloDelegate = () => { MessageBox.Show("Hello world!"); }; _switchOpacityDelegate = () => { Opacity = _isOpacitySwitched ? 0.60 : 1; _isOpacitySwitched = !_isOpacitySwitched; }; _switchBackColorDelegate = () => { BackColor = _isBackColorSwitched ? Color.Red : _defaultColor; _isBackColorSwitched = !_isBackColorSwitched; }; }
public void CheckService() { try { client.CheckService(); } catch (Exception ex) { if (this.InvokeRequired) { var form = new FormDelegate(CheckService); this.checkService.Change(Timeout.Infinite, Timeout.Infinite); this.checkService.Dispose(); this.Invoke(form); } else { MessageBox.Show("The OPC Service has not been started yet or has encountered an error. Please restart it."); this.Close(); System.Environment.Exit(1); } } }
static public void Start(Control parent) { try { Rectangle rect = (parent == null) ? Rectangle.Empty : parent.RectangleToScreen(parent.ClientRectangle); close = false; FormDelegate d = delegate() { WaitForm frm = new WaitForm(); if (rect != Rectangle.Empty) { frm.StartPosition = FormStartPosition.Manual; frm.Location = new Point(rect.Left + (rect.Width - frm.Width) / 2, rect.Top + (rect.Height - frm.Height) / 2); } System.Windows.Forms.Timer tm = new System.Windows.Forms.Timer(); tm.Interval = 50; tm.Tick += new EventHandler(delegate(object sender, EventArgs e) { if (close) { frm.Close(); } else { Application.DoEvents(); } }); tm.Start(); frm.ShowDialog(); }; d.BeginInvoke(null, null); } catch (Exception exp) { throw exp; } }
private void button4_Click(object sender, EventArgs e) { MessageBox.Show("Super button!"); _emptyFormDelegate = CheckStateMethod; _emptyFormDelegate(); }
private void interpreter_PositionReceived(string latitude, string longitude, string elevation) { GeminiHardware.Instance.Trace.Enter("frmGPS PositionReceived", latitude, longitude, elevation); FormDelegate message = new FormDelegate(ProcessForm); this.BeginInvoke(message, new Object[] { latitude, longitude, elevation }); GeminiHardware.Instance.Trace.Exit("frmGPS PositionReceived"); }