28 February 2020, 10:30
|
#6
|
Registered User
Join Date: Feb 2020
Location: Munich/Germany
Posts: 2
|
Quote:
Originally Posted by BastyCDGS
Another possibility is to Lock() your program's executable with exclusive access mode straight after start.
This way you get a meaningful error message via IoErr() (202: object is busy), if it's opened again.
However, there is a caveat, if your program crashes, the lock might remain open forever, so prepare special cleanup code for this.
The FindPort solution is nice, too, but you should be careful about name collisions with other applications running.
And beware of race conditions occuring by both methods! Always sempahore protect such code!
|
wanted to advice the same.
|
|
|