1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-07 08:34:06 +02:00

Fix LockManager to check process name before reporting, and cleanup Close/Dispose code

Closes 
This commit is contained in:
chylex 2016-04-23 16:51:11 +02:00
parent 4cef0fb60d
commit 016e403309

View File

@ -54,7 +54,15 @@ public bool Lock(){
int pid = BitConverter.ToInt32(bytes,0);
try{
lockingProcess = Process.GetProcessById(pid);
Process foundProcess = Process.GetProcessById(pid);
using(Process currentProcess = Process.GetCurrentProcess()){
if (foundProcess.ProcessName == currentProcess.ProcessName){
lockingProcess = foundProcess;
}
currentProcess.Close();
}
}catch(ArgumentException){}
return lockingProcess == null && CreateLockFile();
@ -76,7 +84,6 @@ public bool Lock(){
public void Unlock(){
if (lockStream != null){
lockStream.Close();
lockStream.Dispose();
File.Delete(file);
@ -96,7 +103,7 @@ public bool CloseLockingProcess(int timeout){
}
if (lockingProcess.HasExited){
lockingProcess.Close();
lockingProcess.Dispose();
lockingProcess = null;
return true;
}