Re: Changing a variable inside of TThread from outside of the Thread.



Tom de Neef wrote:
1) I would not put Resume in the creator. If you want the thread to start upon creation, use Create(false). Check help: the parameter tells whether to start immediately or wait until resume is called.

In certain versions of Delphi, that won't work. In those versions, when you use CreateSuspended = False, the thread begins running as soon as you call the inherited constructor. Thus you need to be careful about where you call the inherited constructor. If you call it before all the fields are set, then you have a race condition.

In later versions of Delphi, TThread will delay starting the thread until the AfterConstruction call, even when CreateSuspended is False, so it no longer matters when the inherited constructor gets called.

--
Rob
.