BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single Thread problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal
View previous topic :: View next topic  
Author Message
JAFO
Guest





PostPosted: Mon Jan 19, 2004 8:54 pm    Post subject: Single Thread problem Reply with quote



I have an intermittent problem with my application whenever it starts a
thread. It works fine with no errors except half the time it won't finish...
It just stops - mainly after I've done a lot of mouse-clicks in the main
application on a scrollbar but other input causes the thread to quit. It
doesn't hang my app nor does it signal that it has been terminated. Trying
to 'resume' it does nothing either.

It's the only thread in the app.



--------------------------------------------------------
Start Thread...
--------------------------------------------------------

MyThread := TMyThread.Create(true);
MyThread.priority:=tplower;
MyThread.resume;
IsRunning:=true;

while IsRunning do Application.ProcessMessages; //same results without
this

--------------------------------------------------------
What the thread does...
--------------------------------------------------------

procedure TMyThread.Execute;

for i:=1 to FileListGrid.rowcount-1 do begin

if Terminated then break;

//do lot's of processing here with:
//streams, images, disk I/O... things on the main form, etc
//uses a few procedures from the main form


end; //i loop

UpdateCaption(i); //update formmain's progressbar defined in
"TMyThread.UpdateCaption"

end;

--------------------------------------------------------


Back to top
CrashCodes
Guest





PostPosted: Tue Jan 20, 2004 12:19 am    Post subject: Re: Single Thread problem Reply with quote



"JAFO" <xcaliber (AT) future (DOT) net> wrote

Quote:
I have an intermittent problem with my application whenever it starts a
thread. It works fine with no errors except half the time it won't
finish...
It just stops - mainly after I've done a lot of mouse-clicks in the main
application on a scrollbar but other input causes the thread to quit. It
doesn't hang my app nor does it signal that it has been terminated. Trying
to 'resume' it does nothing either.

It's the only thread in the app.



--------------------------------------------------------
Start Thread...
--------------------------------------------------------

MyThread := TMyThread.Create(true);
MyThread.priority:=tplower;
MyThread.resume;
IsRunning:=true;

while IsRunning do Application.ProcessMessages; //same results without
this

--------------------------------------------------------
What the thread does...
--------------------------------------------------------

procedure TMyThread.Execute;

for i:=1 to FileListGrid.rowcount-1 do begin

if Terminated then break;

//do lot's of processing here with:
//streams, images, disk I/O... things on the main form, etc
//uses a few procedures from the main form


end; //i loop

UpdateCaption(i); //update formmain's progressbar defined in
"TMyThread.UpdateCaption"

end;

--------------------------------------------------------


How does this loop ever finish?

while IsRunning do Application.ProcessMessages;



Back to top
James Mauldin
Guest





PostPosted: Tue Jan 20, 2004 4:10 am    Post subject: Re: Single Thread problem Reply with quote




Quote:
while IsRunning do Application.ProcessMessages; //same results without
this

<snip>

Quote:
//do lot's of processing here with:
//streams, images, disk I/O... things on the main form, etc
//uses a few procedures from the main form


You haven't provided enough information to make it possible to determine the
cause. But one wonders ... why are you calling Application.ProcessMessage
in the main thread? The main thread will go about its business while the
other thread is processing.

If you can't restart your thread, is FreeOnTerminate set to True? In the
"do lots of processing part", are you using Synchronize to do "Things on the
main form"?

-- James











Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.