How can I parallelize spellcheck with Delphi?

I have a kind of spell check written in Delphi. It analyzes the text sentence by sentence. He fixes the wrong position in accordance with some rules after parsing each sentence. The user can interrupt this process, which is important. How can I parallelize this process in general using some third-party Delphi libraries? In the current state, after checking, I received the color of the proposal. Thus, the user sees progress.

+5
source share
2 answers

The algorithm would be like this:

  • Create multiple workers.
  • Create a spellcheck for each worker.
  • ( ). .
  • . - , . , .
  • , ( ) .
    • - .
    • , ( , ), ( , OnIdle).

, . , ( ). , , .

OmniThreadLibrary ParallelTask ​​, BackgroundWorker.

+9

, TThread, , , Execute .

:

TMySpellChecker = class(TThread)
protected
  FText: String;
  FResult: String; 
public
  procedure Execute; override;
  property Text: String read FText write FText;
  property Result: String read FResult write FResult;
end;

TMySpellChecker.Execute;
begin
  // Analyze the text, and compute the result
end;

:

NewThread := TMySpellChecker.Create(True); // Create suspended
NewThread.Text := TextSegment;
NewThread.Execute;

, .

, OnTerminate :

NewThread.OnTerminate := HandleMySpellCheckerTerminate;

, Execute .

, , , . .

+4

All Articles