0

This is my code, it works only on form load or click.

But I need to show this msgbox when process close while my app running.

Dim p() As Process
    p = Process.GetProcessesByName("notepad")
    If p.Count > 0 Then
        ' Process is running
        MsgBox("Running!")
    Else
        ' Process is not running
        MsgBox("Not running!")
    End If
mvydvyspy
  • 25
  • 6

1 Answers1

0

So, you want to monitor the status->Running or status->NotRunning of a process,
while your Application is executing.
This requires a method that continuously updates the Status of a monitored foreign process.

How this method works, depends on you application functionality:

I suggest you learn how to instantiate a BackgroundWorker.
It's a very straightforward and helpful tool to use if you don't want to manually control an
Asynchronous task.

A BackgroundWorker can be instructed to notify your main process (application) that a defined condition has changed.
When this condition is met, the BW raises an Event, letting you know what happend or changed.
Then you decide how to proceed, or - if it is the case - you can terminate the activity of the BackgroundWorker.
Give it a try.

Jimi
  • 29,621
  • 8
  • 43
  • 61