TThread Behavior Synchronization

From what I understand, calling TThread Synchronize will execute the synchronized code, as if it were executing in the main thread. Let's say that in my main topic I have one button:

procedure TForm3.Button1Click(Sender: TObject);
var
 A, B, C : String;
begin
 A := 'test1';
 B := 'test2';
 C := 'test3';
 Button1.Enabled := false;
end;

In the secondary stream, I have the following code:

procedure TestThread.ChangeButton1;
begin
 Form3.Button1.Enabled := true;
end;

(Do not pay attention to the code itself - this is just an example, and it should not mean anything.)

Let's say I press Button1 , and right after that, when Button1Click is executed , TestThread calls Sync (ChangeButton1); . Can we know when ChangeButton1 will be launched by the main thread? If yes, then it will be after all Button1Click is done ; or can he be among any of the four operations within the procedure?

, . . , Synchronize.

.

+4
2

.

, " " - . - , Synchronize, Synchronize , . , , , , .

, mid-stream - .

+5

A Synchronize() , , , . , Synchronize(). Button1Click() , , Button1Click(). Synchronize(), , . , , ChangeButton1() Button1Click().

+7

All Articles