Difficult Task

  • Thread starter Thread starter Laserson
  • Start date Start date
L

Laserson

Hi all! I have a very difficult task for me and i can't so it. My task:

I have created an application. But how to determine that it is not
responding??? You can see it when windows add "Not Responding" to
application title, but how to catch it from application?

I hope you'll help...
 
Hello Laserson,

Heh. Lets examine what you are asking...
You want your application, which has stopped responding, to itsself generate
a response detailing it's non-responsiveness. That's like shooting a guy
in the head and then asking to the corpse to call the morgue and arrange
it's own funeral. Neat trick if it were possible.. but no possible with
our current technology.

Only thing you can do is duplicate the Task Manager functionality.. monitor
your process from another application.

-Boo
 
Laserson,

The same as

"Can God lift a stone that he has made himself not liftable"

Cor
 
Boo

nice answer,

Cor

GhostInAK said:
Hello Laserson,

Heh. Lets examine what you are asking...
You want your application, which has stopped responding, to itsself
generate a response detailing it's non-responsiveness. That's like
shooting a guy in the head and then asking to the corpse to call the
morgue and arrange it's own funeral. Neat trick if it were possible.. but
no possible with our current technology.

Only thing you can do is duplicate the Task Manager functionality..
monitor your process from another application.

-Boo
 
It is possible, and simple - so you don't have to shoot yourself in the
hand.

"Not responding" means that the main thread is not responding to
messages - it does not mean that the application is hanging.

You can try to use a backgroundthread, wich checks the program using
GetProcessesByName.

Sample:

Public Class Form1
Private WithEvents bgt As New System.ComponentModel.BackgroundWorker

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Show the form
Me.Show()
Me.Refresh()
'Start the background worker
bgt.RunWorkerAsync()

Do
'and hang the app
Loop

End Sub

Private Sub bgt_DoWork(ByVal sender As Object, ByVal e As
System.ComponentModel.DoWorkEventArgs) Handles bgt.DoWork
Dim myprocess As Process = Process.GetCurrentProcess()

Do
Threading.Thread.Sleep(1000)
If myprocess.Responding Then
Debug.Print("Responding")
Else
Debug.Print("Not responding")
End If
Loop
End Sub
End Class
 
Back
Top