 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
JAFO Guest
|
Posted: Mon Jan 19, 2004 8:54 pm Post subject: Single Thread problem |
|
|
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
|
Posted: Tue Jan 20, 2004 12:19 am Post subject: Re: Single Thread problem |
|
|
"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
|
Posted: Tue Jan 20, 2004 4:10 am Post subject: Re: Single Thread problem |
|
|
| 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 |
|
 |
|
|
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
|
|