Is TRVHunSpell thread-safe and can be used for multiple editors?

General TRichView support forum. Please post your questions here
Post Reply
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Is TRVHunSpell thread-safe and can be used for multiple editors?

Post 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.
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Re: Is TRVHunSpell thread-safe and can be used for multiple editors?

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Is TRVHunSpell thread-safe and can be used for multiple editors?

Post by Sergey Tkachenko »

Yes, there will be one thread for each editor.
So I recommend to protect OnSpellingCheck code by a TCriticalSection.
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Re: Is TRVHunSpell thread-safe and can be used for multiple editors?

Post by edwinyzh »

Great, it's a piece of cake!
Post Reply