You've found a bug in ScintillaNET.
To handle interop between the managed Scintilla wrapper and the native Scintilla control, ScintillaNET overrides the WndProc method. In so doing, it appears the Windows Forms mechanism for marshaling calls back to the UI thread has been broken.
In the meantime, you can use the BackgroundWorker.ProgressChanged event which is there to do precisely the type of periodic UI update you are attempting.
After making sure you've set the BackgroundWorker.WorkerReportsProgress property to true
, modify your code so that you use the BackgroundWorker.ReportProgress method in place of your Invoke method and handle the ProgressChanged event.
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
string x;
while (true)
{
x = "Your telnet data";
Thread.Sleep(100);
worker.ReportProgress(-1, x);
}
}
private void bg_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
string text = e.UserState as string;
scintilla1.AppendText(text);
}
(full disclosure: I'm a ScintillaNET developer)