Sam Hobbs
posted
6490 posts
since
Sep 07, 2009
from
Los Angeles, California, USA
|
|
Re: UI freezes occasionally
|
|
|
|
|
|
|
|
|
|
|
So you give the UI a lower priority and the UI must be responsive? I think the first thing you need to do is to decide which of those incompatible requirements you want.
One very simple diagnostic technique is to use the Task Manager. I keep it running. You can minimize it to the status area and still see a graph that indicates processor utilization. When the UI freezes, glance down at the Task Manager wherever it is to determine if the processor is maxed out. If the UI freezes with the processor maxed out, then you know it is futile to attempt to satisfy both incompatible requirements. If tyhe processor is not busy, then you know you must proceed in a very different direction.
|
|
|
|
|
Thinking is a feeling; pleasant for some and unpleasant for others.
|
|
|
|
|
|
Alex
posted
4 posts
since
Jul 28, 2010
from
|
|
Re: UI freezes occasionally
|
|
|
|
|
|
|
|
|
|
|
A good suggestion. However since most occasions of freezes occur at our customers' machines, I'm afraid it would be hardly feasible to induce them to occasionally glance at the Task Manager's info. That's why we really need a way of dealing with this in an automated fashion.
|
|
|
|
|
|
Sam Hobbs
posted
6490 posts
since
Sep 07, 2009
from
Los Angeles, California, USA
|
|
Re: UI freezes occasionally
|
|
|
|
|
|
|
|
|
|
|
Why is the UI thread a lower priority? Does it do a lot of processing?
|
|
|
|
|
Thinking is a feeling; pleasant for some and unpleasant for others.
|
|
|
|
|
|
Alex
posted
4 posts
since
Jul 28, 2010
from
|
|
Re: UI freezes occasionally
|
|
|
|
|
|
|
|
|
|
|
The UI thread is a lower priority simply because worker threads are more critical. It's alike WM_PAINT having low priority in Windows. It's better for UI to be occasionally unresponsive than for the modules doing business logic.
|
|
|
|
|
|
Sam Hobbs
posted
6490 posts
since
Sep 07, 2009
from
Los Angeles, California, USA
|
|
Re: UI freezes occasionally
|
|
|
|
|
|
|
|
|
|
|
Note that that does answer my previous request for clarification. Does the UI do a lot of processing? If not then giving it a higher priority won't degrade performance, unless you are concerned about the time for context switches. If it does do a lot of processing then offloading processing from the UI thread to a separate thread could help.
|
|
|
|
|
Thinking is a feeling; pleasant for some and unpleasant for others.
|
|
|
|
|
|
Alex
posted
4 posts
since
Jul 28, 2010
from
|
|
Re: UI freezes occasionally
|
|
|
|
|
|
|
|
|
|
|
Yeah I missed your second question. In certain situations the UI thread uses a lot of CPU but I don't think that was the case at the times when freezes were observed. Therefore your suggestion is worth consideration.
At the moment I'm thinking about periodically noting down CPU usage with PerformanceCounter, introducing a special thread for that. That way we will perhaps be able to answer the question from your first post, whether the CPU is the bottleneck. Do you see any problems with this approach?
Also, do you know whether there are ways to log context switches and CPU usage by threads? I believe there are tools (ProcessMonitor?) that visualise this information but what we need is logging.
|
|
|
|
|
|
Sam Hobbs
posted
6490 posts
since
Sep 07, 2009
from
Los Angeles, California, USA
|
|
Re: UI freezes occasionally
|
|
|
|
|
|
|
|
|
|
|
The performance monitor is a COM object or some type of component.
|
|
|
|
|
Thinking is a feeling; pleasant for some and unpleasant for others.
|
|
|
|
|
|