Re: UI has highest thread priority, yet it is still slow when background threads work
- From: "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com>
- Date: Thu, 5 Oct 2006 10:32:33 -0700
The UI shouldn't be calling anything that will block for *any* significant
period of time, other than GetMessage(), in the main message loop.
Paul T.
<rpatel4@xxxxxxxxx> wrote in message
news:1160067946.268231.53550@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
"the data being displayed has no relationship to anything that any of
the threads are doing"
This is not completely true.
You're info does clear things up. If its not a priority issue, the
slowness must be due to the UI blocking on a locked object, and I'll
step thru the UI code looking for any blocking calls (I don't know for
sure if they exist since I didn't write most of this app).
Thanks...
Paul G. Tobey [eMVP] wrote:
And the data being displayed has no relationship to anything that any of
the
threads are doing? Remember that the scheduler always will give *all* of
the processor time to the highest-priority thread which is ready to run.
If
your main program thread, for example, is always ready to run (as an
example, let's say it's a while loop that never blocks on any call that
it
makes), the other threads will get *zero* time, starving them completely.
It must be some interaction between the threads, then, which is causing
the
effect that you're seeing.
Paul T.
<rpatel4@xxxxxxxxx> wrote in message
news:1160058984.735259.124600@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
HI Paul,
Thanks for the info.
As far as how I'm determining that the UI is slow...I've got a panel
that contains a list of items (its an owner drawn list), and I've got a
combo box that when I click(or key) right or left, it refreshes the
panel with different items. Anyways, the movement up/down the list, as
well as left/right in the combo box is considerably slower when the
background threads are going at it, then it is when the background
threads are idle.
The thread priorities appear to be set correctly (I'm reading the
priority into an int and setting a breakpoint and the priority's int
value is correct).
It code be that background (the network's interrupt handler) has
priority over my app threads and thus are slowing down UI. As a test,
I'll throw in a sleep(1) after every network call and if that solves it
(its not an ideal solution) I'll move on for now.
Thanks,
R Patel
Paul G. Tobey [eMVP] wrote:
I wouldn't think it would cause a huge slowdown, but when you're doing
network activity, there are a lot of higher-than-you priority threads
running (the interrupt handler for the network chip, for example).
What
sort of method are you using to decide that the UI is slow? What is
it
doing? And, just to be sure, you *are* setting that priority in the
context
of your background thread, right? Not accidentally changing the
priority
of
the UI thread?
Paul T.
<rpatel4@xxxxxxxxx> wrote in message
news:1160001475.924096.314930@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I've got about 5 thread in my application.
One of the threads downloads data from the internet
I gave the UI the highest priority
System.Threading.Thread.CurrentThread.Priority =
System.Threading.ThreadPriority.Normal;
I gave all other threads a lower priority
_threadObject.Priority =
System.Threading.ThreadPriority.BelowNormal;
Yet when the background threads are downloading data, the UI is
noticeably slower.
Am I doing something wrong here, is there any other way to get the
UI
to have priority over the background?
(While I was writing this I came up with a possible issue -- that a
background thread has acquired a mutex and the UI is blocking until
the
background releases that mutex -- I'll check this code for this but
if
its not any other solutions?)
.
- References:
- UI has highest thread priority, yet it is still slow when background threads work
- From: rpatel4
- Re: UI has highest thread priority, yet it is still slow when background threads work
- From: Paul G. Tobey [eMVP]
- Re: UI has highest thread priority, yet it is still slow when background threads work
- From: rpatel4
- Re: UI has highest thread priority, yet it is still slow when background threads work
- From: Paul G. Tobey [eMVP]
- Re: UI has highest thread priority, yet it is still slow when background threads work
- From: rpatel4
- UI has highest thread priority, yet it is still slow when background threads work
- Prev by Date: Re: UI has highest thread priority, yet it is still slow when background threads work
- Next by Date: Re: Hiding column in Datagrid
- Previous by thread: Re: UI has highest thread priority, yet it is still slow when background threads work
- Next by thread: File Download Problem-c#
- Index(es):
Relevant Pages
|