Whats the best way to run a function that syntax highlights text in a text box (left of = is red, right of = is blue). I ask because I had the data retrival in a CommandTask thread, and then did the highlighting in the FinishCommand (in UI thread) and that seemed to work but would deadlock the UI for a bit while it chugged away highlighting.
So, then I tried placing the highlighting code in a specalized RichTextBox Invoke function (thus thread safe) and moved the function call in the thread. That also worked, but for some reason was consistantly 4-8 seconds slower; this makes no sense to me because its the exact same code.
Finally, I tried making a temp RichTextBox in the thread, pasting the resulting text to it and highlighting. Then, all the Invoke function did was pass along the RTF to the real RichTextBox, but in this case for some reason the RTF isn't quite right, its the color gets shifted by 2 each time Ex: R=red, B=Blue, X=Black chars
Line 1. RRRRXBBBB (correct)
Line 2. XXRRRRBBB (coloring shifted 2 to the right)
Line 3. XXXXRRRRX (shifted 4 to the right, and so on)
So, my overarching question is which approach is best, why is threading the exact same code slower, and if approach 3 is the best, whats up with that wierd color shifting. Thanks!