BPV01Team2 / PomodoroTracker

The Second Project
0 stars 0 forks source link

Можливість не відкривати вікно програми більше 1 одночасно(якщо це можливо). #25

Open pertsov opened 2 years ago

pertsov commented 2 years ago

2

pertsov commented 2 years ago

// Make sure that appMutex has the lifetime of the code to guard -- // you must keep it from being collected (and the finalizer called, which // will release the mutex, which is not good here!). // You can also poke the mutex later. Mutex appMutex;

// In some startup/initialization code bool createdNew; appMutex = new Mutex(true, "mutexname", out createdNew); if (!createdNew) { // The mutex already existed - exit application. // Windows will release the resources for the process and the // mutex will go away when no process has it open. // Processes are much more cleaned-up after than threads :) } else { // win \o/ }

pertsov commented 2 years ago

https://ayende.com/blog/3169/the-mysterious-life-of-mutexes