Cheat Sheet

Friday, February 3, 2017

Simple Advisory Lock for C# via Mono

Mono handled mutex differently from Microsoft dotNET due to platform differences (eventhough the implementation is the same).

So the only simplest method to create mutex-like for advisory lock on mono is by creating a lock file. Criteria:

1. Only one instance of application can be run one time. (not to be confuse application with software and thread!)
2. After the application exit, the application can be run again. (Proper cleanup!)

Hence, this is the simple class for that.


https://gist.github.com/fawildchild/d1ccbf26af5931da6c138599ddd10de6

Straight forward I say.

(ps: Console.ReadKey() at the end)


Walla

No comments:

Post a Comment