473,385 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to programatically check if an application has hang ?

Hi,

I need to write a monitoring program to check a series of application
residing in a server.

The monitoring program should be able to :-
1) Determine whether the applications it is looking at has hangup.
2) If it hangs restart the specific app.
And, how do we differentiate the app is busy or it was indeed dead?
Thank You.
mfwoo
Oct 13 '06 #1
2 5056
Hi Woo,

Windows Task Manager is able to detect this.

It uses API call SendMessageTimeout. The call sends a message to the
app, then waits up to the specified timeout period for the message to
be processed. If the message was never processed, it means the app is
likely hung.

Of course, the application might just be *busy* and not paying
attention at the moment. So you must choose an appropriately long
timeout.

If you happen to be writing the app that will be monitored, you can
ensure that it will always respond to these messages in a timely
fashion by either:
1) Periodically calling DoEvents in any code that might take a while
to execute.
2) Making sure such code is processed in a separate thread than the
one that controls the UI, and therefore the message handler.

Check out this article from MS. The title is incorrect (!), but it
really does deal with your question, and gives virtually all the code
you need for your monitoring program:

http://support.microsoft.com/kb/304990/

Oct 13 '06 #2
Thanks a lot

Regards,
mfwoo

"te******@hotmail.com" wrote:
Hi Woo,

Windows Task Manager is able to detect this.

It uses API call SendMessageTimeout. The call sends a message to the
app, then waits up to the specified timeout period for the message to
be processed. If the message was never processed, it means the app is
likely hung.

Of course, the application might just be *busy* and not paying
attention at the moment. So you must choose an appropriately long
timeout.

If you happen to be writing the app that will be monitored, you can
ensure that it will always respond to these messages in a timely
fashion by either:
1) Periodically calling DoEvents in any code that might take a while
to execute.
2) Making sure such code is processed in a separate thread than the
one that controls the UI, and therefore the message handler.

Check out this article from MS. The title is incorrect (!), but it
really does deal with your question, and gives virtually all the code
you need for your monitoring program:

http://support.microsoft.com/kb/304990/

Oct 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rahul Apte | last post by:
How do I programmatically check whether ASP and Server Side Includes sub-components of the World Wide Web service are installed on a Windows 2003 Box? I want to do these checks as pre-install...
4
by: Br | last post by:
We're using an Access2000 ADP with an SQL2000 back-end. Because SQL2000 was released after Access2000 you need to be running Access2000 SP1 (2 or 3) for it to work properly. Is there an easy way...
3
by: dje | last post by:
How do I determine if the current process is a Web Application or Windows Application? I've tried: System.Diagnostics.Process process=System.Diagnostics.Process.GetCurrentProcess(); but it...
5
by: Loane Sharp | last post by:
Hi there I've got a hang of a problem ... I'm running the .NET framework (2.0.40903), SQL Server 2000 and SQL Express 2005 on Windows XP Pro on a pretty good and new IBM Thinkpad X41. Some...
2
by: agus liem | last post by:
Hai.. I introduce myself, my name : Agus, from Indonesia. Im develop application using POwerbuilder 7 and postgresql 7.3. I have serveral error, and cannot solve yet. Anybody help me? This is...
2
by: Chris Dunaway | last post by:
I need to be able to start and stop a service on another computer on the network. But I cannot connect to the other computer using my standard user credentials. I have a separate login for that...
8
by: Rak | last post by:
I am looking for a way to programatically change the .net version of the virtual directory that I am creating within a aspx page. As part of creating a new customer in my asp.net 2 application, it...
0
by: Simon | last post by:
I have a problem with an application which randomly hangs on site. The symptoms are that the user will click a button - which normally would open a new form (which inevitably will create a socket...
3
by: =?Utf-8?B?UGF1bA==?= | last post by:
I need to programatically upload a text file to a web server using the HTTPWebRequest object within .Net 2.0. So far, I have determined that: - I need a HTTP content-type of...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.