What I want to achieve:
- when I run application from start menu, app starts (if app not running).
- If an app is already running, then don't create another instance, just show the previous running app window.
What I've tried:
- created a
.txt file
in a directory, write 'running
' & 'not running
' into the file while opening & exiting the window. And checking the file contents at very start. For ex: When starting app: 1.) Check the file content, 2.) If file content is 'running
', show warning & exit the app 3.) If file content is 'not running
', write 'running
' into the file & start app 4.) Write 'not running
' into the file on exit.
Issues I'm facing:
This method doesn't feel like the right way to achieve this.
If file item says '
not running
', app shows warning and exits. While I want it to show already running instance.File items not updated to '
not running
' when app exits because of some error in code (because that part is never reached due to error)
Can anybody please help me out regarding this?