Tuesday, December 06, 2005

"How To Detect If an Application Has Stopped Responding by Using Visual Basic .NET"

How To Detect If an Application Has Stopped Responding by Using Visual Basic .NET

"In some situations, you may want to detect if an application is blocked. For example, when you are automating Microsoft Internet Explorer, you may want to know if Internet Explorer has stopped responding.

This article describes how to detect whether an automated instance of Internet Explorer has stopped responding (hung) and how to close Internet Explorer. Although the code is written for Internet Explorer and Visual Basic .NET, you can use this approach for other applications as well.

...

procs = Process.GetProcessesByName("IEXPLORE")
...
Try
If procs(0).Responding = True Then
MessageBox.Show("IEXPLORE is responding")
Else
MessageBox.Show("IEXPLORE is not responding")
End If
Catch
MessageBox.Show("IEXPLORE is not running")
End Try
...
Try
If procs(0).Responding Then
procs(0).CloseMainWindow()
Else
'Force closure.
procs(0).Kill()
End If

Catch notRunning As Exception When Err.Number = 91
MessageBox.Show("Could Not Find the IEXPLORE Process")

End Try

..."

Nice... I dig the .Net Framework. It just makes some things sooooo much easier.

(via Braulio Díez Botella - How to detect if a process is not responding)

2 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Thanks for the tip. I was looking for C# code, but the conversion is trivial.

    ReplyDelete

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...