I'm building a component (as mentioned in some previous posts) which has a custom thread of mine inside. I have come to find out that when I drop this final component onto a form (or data module), it executes the thread somehow, when I don't have a single thing in this component which shall execute the thread just on create. I made it so it only executes on demand. I also made sure that in the thread's creation, I'm forcing it to create suspended. The only place I ever execute this thread is in one procedure which resumes the thread, and is only called on demand (like a button click) but I have proof that it is in fact executing anyway.
The question is, besides figuring out where it's executing, how do I use conditional defines to block it from performing certain code in design time?
something like...
I know this is possible, but what's the conditional to use?
Also, any suggestions on the thread executing without me telling it to?
This is the inherited create constructor for the thread...
JD Solutions
The question is, besides figuring out where it's executing, how do I use conditional defines to block it from performing certain code in design time?
something like...
Code:
procedure RefreshList;
begin
if assigned(fOnStart) then fOnStart(Self);
{$IFNDEF DESIGN}
Self.Resume;
{$ENDIF}
end;
I know this is possible, but what's the conditional to use?
Also, any suggestions on the thread executing without me telling it to?
This is the inherited create constructor for the thread...
Code:
constructor TNetResourceScanner.Create;
begin
fBusy:= True; //Tell anything trying to access it that it's busy right now
try
inherited Create(True); //Creating suspended
FreeOnTerminate:= True; //Make sure it free's when it terminates
Priority:= tpHigher; //Speed things up a little
fStop:= True; //If for some reason it is executing, this tells the thread to stop executing
finally
fBusy:= False; //Not busy anymore
end;
end;
JD Solutions