Solved

Thread problem

Posted on 2004-09-25
8
352 Views
Last Modified: 2010-04-06
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;

0
Comment
Question by:ginsonic
  • 4
  • 2
  • 2
8 Comments
 
LVL 6

Accepted Solution

by:
vadim_ti earned 250 total points
Comment Utility


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

Assisted Solution

by:Ferruccio Accalai
Ferruccio Accalai earned 250 total points
Comment Utility
vadim_ti is right....(he deserves the points)

Now just to explane it you can change the default Priority just when the Thread is already created otherwise the error is raised as there's no handle for the Thread, tyhat means that the System try to execute scheduled a non-handled Thread....

So you can also write your constructor as

constructor TGNThread.Create( AnimateMe : TgnClass );
begin
   Animated                 := AnimateMe;
   OnTerminate           := Animated.Fine;
   FreeOnTerminate     := True; //'til here the Thread handle isn't needed as these are just Object properties
   inherited Create ( true);
   Priority                    := tpNormal; //but this needs the Thread handle in process
   Resume; //Now let's resume it
end;

0
 
LVL 9

Author Comment

by:ginsonic
Comment Utility
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!
0
 
LVL 9

Author Comment

by:ginsonic
Comment Utility
Sorry , I wish to say:

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

Copy problem :)
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 6

Expert Comment

by:vadim_ti
Comment Utility
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
0
 
LVL 9

Author Comment

by:ginsonic
Comment Utility
Look like resume solve all problems. Suspended make my VCL to not work for all my actions.
0
 
LVL 9

Author Comment

by:ginsonic
Comment Utility
Thanks again for support!
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
Comment Utility
:)) That's why i've used resume in my example :)

F68 ;-)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now