Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This looks like it should work, maybe it has some thing to do with concurrency.<br> Try using <code>comBox.Invoke(...)</code> instead of <code>comBox.BeginInvoke(...)</code><br> <strong>Update:</strong> <strike>The thing is when you use <code>BeginInvoke</code> the method calls may be invoked out of order.</strike><br> That was wrong, calls to <code>Invoke</code> and <code>BeginInvoke</code> are executed in order. </p> <p><strong>Edit:</strong><br> It that doesn´t work make sure you don´t have any other place where you change the text in <code>comBox</code>. </p> <p>If it still doesn´t work you might have to create a lock to make sure you don´t have two thread simultaneously writing to the textbox.</p> <p>Something like this:</p> <pre><code>private static readonly object _comBoxSyncObj = new object(); public void LogComText(string comText, bool newline) { if (comBox.InvokeRequired) { comBox.Invoke(new Action(delegate { LogComText(comText, newline); })); return; } lock (_comBoxSyncObj) { comBox.AppendText(comText); if(newline) comBox.AppendText(Environment.NewLine); } } </code></pre> <p><strong>Edit2:</strong><br> If the problem persists, you can add an event handler for the <code>TextChanged</code> event and put a breakpoint in it to se when the textbox get cleared. </p> <p>Add this method and an eventhandler for <code>TextChanged</code> on comBox:</p> <pre><code>private void comBox_TextChanged(object sender, EventArgs e) { if (comBox.TextLength == 0) { // Set a breakpoint here. Trace.WriteLine("TextBox empty"); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload