I have a TextBox which tells the status of a running application (lets say notepad). If notepad is running Text of TextBox is running and not running for other case.
public string ProcessStatus
{
get
{
IsProcessRunning("Notepad.exe")
return "Running";
return "Not Running";
}
}
Now problem here is that view updates itself only once when it is launched. At that time if notepad is running it works fine. Now lets suppose I ran my application and notepad was not running then TextBox says not running. Now I launch notepad, now application is still saying not running as application has not updated the view. If I call notify of property changed event for the TextBox then it will say running. But I want here is that TextBox updates automatically.
The only solution what I am thinking right now is that I start a background process which keeps on updating ProcessStatus
. But is this the right way? Is there any better way? Something like DirectoryWatcher for processes?