Page 1 of 1
Is TRVHunSpell thread-safe and can be used for multiple editors?
Posted: Sun Jun 19, 2022 8:18 am
by edwinyzh
Hi Sergey,
Can one TRVHunSpell object (alone with a TRVAHunSpellInterface) be used by multiple editors for live spell check? As we know, the OnSpellingCheck event is called in a background thread.
Re: Is TRVHunSpell thread-safe and can be used for multiple editors?
Posted: Sun Jun 19, 2022 11:14 am
by edwinyzh
According to the RichViewAtions document:
Create TRVAHunSpellInterface component, assign it to SpellInterface property of TRVAControlPanel component.
Create TRVHunSpell component, assign it to HunSpell property of this TRVAHunSpellInterface component.
Currently I have only a single TRVAControlPanel but have multiple editors. By looking at the TRichViewEdit source code, I found that each editor has its own spell check thread. Does it mean with the approach above, there will be multiple threads accessing the same TRVAHunSpellInterface/TRVHunSpell pair?
Re: Is TRVHunSpell thread-safe and can be used for multiple editors?
Posted: Sun Jun 19, 2022 12:22 pm
by Sergey Tkachenko
Yes, there will be one thread for each editor.
So I recommend to protect OnSpellingCheck code by a TCriticalSection.
Re: Is TRVHunSpell thread-safe and can be used for multiple editors?
Posted: Sun Jun 19, 2022 2:29 pm
by edwinyzh
Great, it's a piece of cake!