Results 1 to 17 of 17

Thread: Detect if program is not responding!

Threaded View

  1. #16
    Lively Member Stupidiot's Avatar
    Join Date
    Apr 2011
    Location
    India
    Posts
    95

    Re: Detect if program is not responding!

    U can create a txt file to check this:
    Every 3 minutes - Timer-60000*3 - the main program “cserver.exe” will write the current time in a file:

    Code:
    WriteAlive()
    Open App.Path & "\Live.txt" For Output As #1
    Print #1, Time$
    Close #1
    Code:
    Private Sub Load () - main program cserver.exe load 
    If App.PrevInstance = True Then
    Unload Me
    Exit Sub
    End If
    Shell App.Path & "\Monitor.exe "
    End Sub
    Code:
    Private Sub Unload() - main program cserver.exe unload
    Open App.Path & "\Log.txt" For Output As #1
    Print #1, "User Closed" & Time$
    Close #1
    KillProcess "Monitor.exe" 'No need to Monitor
    End Sub
    Every 1 minutes - Timer-60000*1- the Monitor program “Monitor.exe” will check the same file and if necessary, kill & Reopen cserver.exe:

    Code:
    CheckAlive()
    Dim TextLine, X
    Open App.Path & "\Live.txt" For Input As #1
       Line Input #1, TextLine
    Close #1
    X = DateDiff("n", TextLine, Time$)
    If X > 3 Then
    KillProcess "cserver.exe" 'Kill
    Open App.Path & "\Log.txt" For Output As #1
    Print #1, "Stopped responding, Killed and re-opened" & Time$    
    Close #1
    Shell App.Path & "\cserver.exe" 'Re-Open
    End If
    Code:
    Private Sub Load () - Monitor program Monitor.exe load 
    If App.PrevInstance = True Then
    Unload Me
    Exit Sub
    End If
    End Sub
    Check this:
    http://www.vbforums.com/showthread.php?t=651961
    Last edited by Stupidiot; Jul 31st, 2011 at 04:07 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width