Is there a way to determine if there is an active installation running in C#? For example, some times if you launch 2 MSIs (or setup.exes) at once one of them will say that there is already installation going on in progress. Is there a way to do that in C#? Say, a se开发者_JAVA技巧lf-resetting registry key (that system resets) or a mutex?
A mutex is the way to go.
bool isFirst;
Mutex m = new Mutex(false, "MyMutex", out isFirst);
If isFirst is false then there is another process running. As for the name if you want this to check across multiple sessions (terminal sessions) then change the code to something like.
Mutex m = new Mutex(false, "Global\\MyMutex", out isFirst);
精彩评论