private String Get_richTextBoxFromSubscribers() { CheckForIllegalCrossThreadCalls = false; // Defeats: Control 'textBoxMsg' accessed from a thread other than the thread it was created on. String retval = ""; // InvokeRequired required compares the thread ID of the calling thread to the thread ID of the creating // thread. If these threads are different, it returns true. if (this.richTextBoxFromSubscribers.InvokeRequired) { try { VoidArgReturningStringDelegate d = new VoidArgReturningStringDelegate(Get_richTextBoxFromSubscribers); retval = (String)this.Invoke(d, new object[] { }); } catch (System.Exception se) { } } else { retval = this.richTextBoxFromSubscribers.Text; } CheckForIllegalCrossThreadCalls = true; return(retval); }
protected override void OnRestore(Stream stream) { _windowsDash = Dashboard.dash; _appendText = new StringArgReturningVoidDelegate(_windowsDash.Output_box().AppendText); _getText = new VoidArgReturningStringDelegate(_windowsDash.getText); if (_text != null) { _windowsDash.Output_box().Invoke(_appendText, _text); } }
private String Get_richTextBoxHistoryResponses() { String retval; // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.richTextBoxHistoryResponses.InvokeRequired) { lock (thisLock) { // 03-28-2017: Testing whether a lock solves the cross thread contention here. https://msdn.microsoft.com/en-us/library/c5kehkcz(v=vs.140).aspx VoidArgReturningStringDelegate d = new VoidArgReturningStringDelegate(Get_richTextBoxHistoryResponses); retval = (String)this.Invoke(d, new object[] { }); // There's a cross thread contention here. } } else { retval = this.richTextBoxHistoryResponses.Text; } return(retval); }
public TwitterDashboard(Dashboard windowsDash) { _windowsDash = windowsDash; _appendText = new StringArgReturningVoidDelegate(_windowsDash.Output_box().AppendText); _getText = new VoidArgReturningStringDelegate(_windowsDash.getText); }