public void addMessageLogText(object sender, MessageEvent e) { if (this.InvokeRequired) { MessageEventCallDelegate ev = new MessageEventCallDelegate(addMessageLogText); this.BeginInvoke(ev, new object[] { sender, e }); } else { this.textBox1.AppendText(e.myTime.ToString() + " " + sender.ToString() + ": " + e.ToString() + "\r\n"); } }
public void addMessageLogText(object sender, EventArgs e) { WordGenerator.mainClientForm.instance.handleMessageEvent(sender, e); if (this.InvokeRequired) { MessageEventCallDelegate ev = new MessageEventCallDelegate(addMessageLogText); this.BeginInvoke(ev, new object[] { sender, e }); } else { MessageEvent message = e as MessageEvent; if (message != null) { textBox1.AppendText(message.myTime.ToString() + " " + sender.ToString() + ": " + message.ToString() + "\r\n"); } else { textBox1.AppendText(sender.ToString() + ": " + e.ToString() + "\r\n"); } } }
public void updateGUI(object sender, EventArgs e) { // This roundabout way of calling this.Invalidate is a thread safe way to have other threads call // form controls. I copied it from .net documentation. if (this.InvokeRequired) { MessageEventCallDelegate ev = new MessageEventCallDelegate(updateGUI); this.Invoke(ev, new object[] { sender, e }); } else { this.Invalidate(true); } }