Link to home
Start Free TrialLog in
Avatar of ginsonic
ginsonicFlag for Romania

asked on

Thread problem

When I try to set:

Priority := tpNormal ;

get next error message:

"Thread error: The handle is invalid (6)"

constructor TGNThread.Create( AnimateMe : TgnClass );
begin
 Animated                 := AnimateMe;
 Priority                    := tpNormal     ; // here is my problem. If delete it all work fine !?!?!?
 OnTerminate           := Animated.Fine;
 FreeOnTerminate     := True;
 inherited Create ( False );
end;

ASKER CERTIFIED SOLUTION
Avatar of vadim_ti
vadim_ti

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Ferruccio Accalai
Ferruccio Accalai
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ginsonic

ASKER

I split the points beacause the real solution was to call firat inherited Create(True);
Don't need to suspend or resume my thread. Just:

 Animated                 := AnimateMe;
 Priority                    := tpNormal     ;
 OnTerminate           := Animated.Fine;
 FreeOnTerminate     := True;
 suspended := false;

 What was interesting is that an old compiled exe what use inherited after ( wrongh way ) run perfect !?!? The new compiled return the error!?!?!?

Thanks for help!
Sorry , I wish to say:

 inherited Create ( true);
 Animated                 := AnimateMe;
 Priority                    := tpNormal     ;
 OnTerminate           := Animated.Fine;
 FreeOnTerminate     := True;

Copy problem :)
Avatar of vadim_ti
vadim_ti

with your contructor without

suspended := false

thread will not run (execute). you will successfully create it, but it will in suspended state

inherited Create(true)

will create it in suspended,
.Execute method will never called

so you need
suspended := false or calling Resume

to resume thread
Look like resume solve all problems. Suspended make my VCL to not work for all my actions.
Thanks again for support!
:)) That's why i've used resume in my example :)

F68 ;-)