|Subject:||Re: Thread Priority|
|Posted by:||Remy Lebeau \(TeamB\) (firstname.lastname@example.org)|
|Date:||Thu, 15 May 2008|
"Ross Levis" <ro…@stationplaylist-dot.com> wrote in message
> I have a thread which uploads a file every few minutes. I recently
> changed the thread priority of my thread to tpIdle as it's not important
> for the upload to occur immediately. Since this change I've had
> reports from several users of my software that the upload procedure
> now occasionally hangs indefinately. They need to terminate and
> restart my app to get it going again. This can be after a few days
> or a few hours.
tpIdle threads are at the very bottom of the priority stack. If your app
does ANYTHING else, your tpIdle thread is going to be preempted, and will
continue to be so whenever your app is not completely idle outside of the
If you want the upload to continue, just with a lower priority than other
threads, I suggest you use tpLower instead of tpIdle. That way, the upload
thread still gets CPU time of its own periodically.
> I've always had 1 or 2 users complain of this problem even with
> the a tpNormal thread as it was before.
Then either your thread code is using TIdFTP incorrectly to begin with, or
you are doing something to deadlock the thread under certain conditions, or
TIdFTP has gotten into a bad state where it is waiting for data from the
server that never arrives.
> I know Indy itself uses threads internally.
The only worker thread that Indy client components (such as TIdFTP) use
internally is when initially connecting to a server. Beyond that, all work
is done in the thread your own code code runs in.
> I was wondering if it is worth (or even possible) to increase the
> priority of these threads?
Thread Priority posted by Ross Levis on Wed, 14 May 2008