Spelling with text fields and user dictionaries slowing down my application in C # WPF

I use WPF text fields inside a WinForm application to check spelling. Every time I create one, I upload the same file as a CustomDictionary. Everything was fine until recently. Now they take a long time to load, up to a second. Some forms have 30 or more, which means delays of almost half a minute. This is similar to Windows 10 (and not to Windows 8, as I wrote). The application works under DotNet 4.0, I tried 4.5 and 4.6 (not 4.61), and all versions are slow.

I saw the sfausts question Spellcheck Text Box in Win10 - Slow and am7zds. Thanks to these, I looked at the GLOBAL registry key in HKEY_CURRENT_USER \ Software \ Microsoft \ Spelling \ Dictionaries. I have 580 records (after trimming records without matching files), and yet everything is going slowly.

Currently, every time I create a TextBox and add a special dictionary to it, in _GLOBAL _

a new record is created,
  • Is there a better way to do something than load a user dictionary from a file each time?
  • Is there a way to reuse the same entry in _GLOBAL_ each time instead of creating a new one?
  • Is there a clean way to clear previous GLOBAL entries created by my application and their corresponding .dic files when closing the application (or when it restarts)?
  • I can completely clear _GLOBAL_ every time I start my application. This returns the speed I want, but what is the disadvantage?

Any advice gratefully received.

+8
source share
3 answers

There are no answers from anyone else, so here is what I did:

  • I made sure that I use CustomDictionaries.Remove in all text boxes with custom dictionaries before closing the form in which they are located. This eliminates new entries in _GLOBAL_ and related files in AppData \ Local \ Temp.

But there will be times when everything goes wrong, or the user just finishes the task, leaving the _GLOBAL_ and .dic entries in place, therefore:

  1. I decided to go further. When I launch my application, I will not only clean the entries in _GLOBAL_ that do not have the corresponding files (as suggested in the previous publication mentioned above), but also to delete all entries related to the .dic files in AppData \ Local \ Temp. My theory is that anyone who left notes there didn’t mean it, otherwise they would probably have saved the .dic file in another folder (as Microsoft Office does).

    try { string[] allDictionaries = (string[])Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Spelling\Dictionaries", "_Global_", new string[0]); if (allDictionaries.Count() > 0) { List<string> realDictionaries = new List<string>(); bool changedSomething = false; foreach (string thisD in allDictionaries) { if (File.Exists(thisD)) { if (thisD.Contains(@"\AppData\Local\Temp\")) { // Assuming that anyone who wants to keep a permanent .dic file will not store it in \AppData\Local\Temp // So delete the file and don't copy the name of the dictionary into the list of good dictionaries. File.Delete(thisD); changedSomething = true; } else { realDictionaries.Add(thisD); } } else { // File does not exist, so don't copy the name of the dictionary into the list of good dictionaries. changedSomething = true; } } if (changedSomething) { Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Spelling\Dictionaries", "_Global_", realDictionaries.ToArray()); } } } catch (Exception ex) { MessageBox.Show(this, "Error clearing up old dictionary files.\n\nFull message:\n\n" + ex.Message, "Unable to delete file", MessageBoxButtons.OK, MessageBoxIcon.Warning); } 

I'm still wondering if it is possible to completely clear the entries in _GLOBAL_, which refer to the files in AppData \ Local \ Temp. Of course, people should not leave important things in a temporary folder ... should they?

What would be very nice is an overload in CustomDictionaries.Add, which allows us to set the name and folder of the .dic file, allowing all text fields in the same application to share the same .dic file and make sure that we do not leave a load of redundant entries and files with seemingly random names hanging in the first place ..... please Microsoft.

+5
source

We have a similar problem: * .dic files are created by our application.net, and MCShield.exe from MCAfee always scans them, because they are created every time you load a form containing spell-check fields. We noticed that MCAfee slows down the application, so loading the form can take from several seconds to several minutes until all these * .dic files are checked.

0
source

@Aymen - could you please share what you did to decide for McAfee specifically. Faced with the same problem, so any information gratefully received ..

0
source

All Articles