Best way to handle hefty event tasks.

Topics: Developer Forum
Sep 10, 2009 at 4:34 PM

Hi Guys,

   What do you think is the best way to handle/implement these sort of tasks?

I want to do stuff that requires constantly knowing when text in the editor changes.  For example, some editors, like Notepad++, will auto-adjust its line numbers margin's width when the line count grows from 9 to 10 (actually from 8 to 9) or from 99 to 100 to create more horizontal space to show the numbers.  Another example would be tracking keywords in all of the text (sort of like syntax highlighting).  Say I wanted a list box to display all phrases that come after a "Title:" tag, I would have to know when the user types in special words (or be able to process the whole thing and look for the keywords, see Considerations).  This would require constant repetetive analysis of the text.

I want it to be fast.  I don't want to slow down the application because it's running some features (multi-threading is possible, but could lead to other snatches where I'd have to implement more code).  The simplest way to implement these would be to attach a delegate to events like OnCharAdded or OnTextInserted, etc... but that (I imagine) would be slow.  I'm new to ScintiallNet and wasn't sure if it has something I'm missing that would make implementing these features easier.

Sep 11, 2009 at 8:08 AM

I'm not sure if it's helpful, but I guess you could use the BackgroundWoker for this.

So every time you want to scan your text, start the Worker asynchronous.


I've done this, for the Autocompletion, so when a Character is added I count it.

If this counter is % 3 (mod) = 0 (more than 3 Characters typed), I start the BackgroundWorker, extracting the Parts I want.

In the end, I fill up the AutoCompleteList with the names.

Hope it helps.

Best regards