6 Months Free & No Setup Fees ASP.NET Hosting!
Skip Navigation Links
C# Corner Home
Forum Home
Latest 50
Unanswered
Win Prizes
All Time Leaders
Jump to CategoryExpand Jump to Category
Login 
    Welcome Guest!
 Search Forum For :  
X
 Login
Please login to submit a new post, reply and edit exiting posts, see user profiles, and access more features. If you are not a registered member, Register here.
User Id / Email:
Password:  
Forgot Password | Forgot UserName
   Home » Bugs and Problems » UI freezes occasionally
       
Author Reply
Alex
posted 4 posts
since Jul 28, 2010 
from

UI freezes occasionally

  Posted on: 28 Jul 2010       
Hello,

We have a bunch of multi-threaded time-critical  C# applications communicating with the outside world via TCP/IP sockets. UI of any of these applications can occasionally get frozen for a few seconds (in extreme cases up to 30 seconds). This does not happen often and can perhaps be explained by some unusual conditions that occur from time to time on any Windows system. As far as we could ascertain from the logs, these delays only occur on the UI thread, which is usually running with lower priority than worker threads of the application.

Since the applications in question are time-critical as I said, even those rare delays are subject of our investigation; however their random character greatly hinders any analysis. It is possible that there is no miracle solution to the problem, but we need at least to be able to determine in each particular case, what was the cause of the delay.

Now my question: is there any way to:

1)      Detect an "abnormal" delay (i.e. determine that the application is not just idle, it's waiting for something).

2)      Determine the cause of such delay.

Obviously either some internal tracing/debugging/hooking or/and usage of an external observing tool is needed. Any ideas and suggestions will be greatly welcomed.


TIA


Sam Hobbs
posted  6490 posts
since  Sep 07, 2009 
from  Los Angeles, California, USA

 Re: UI freezes occasionally
  Posted on: 28 Jul 2010        0  

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
  Posted on: 28 Jul 2010        0  
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
  Posted on: 29 Jul 2010        0  
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
  Posted on: 29 Jul 2010        0  
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
  Posted on: 29 Jul 2010   Accepted Answer     0  
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
  Posted on: 29 Jul 2010        0  

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
  Posted on: 29 Jul 2010        0  
The performance monitor is a COM object or some type of component.
Thinking is a feeling; pleasant for some and unpleasant for others.
       
6 Months Free & No Setup Fees ASP.NET Hosting!
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Team Foundation Server Hosting
 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Advertise with us
Current Version: 5.2011.3.12
 © 1999 - 2012  Mindcracker LLC. All Rights Reserved