mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-09-02 07:15:31 +00:00
Fixed Issue 220.
This commit is contained in:
@@ -39,6 +39,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security.AccessControl;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@@ -172,7 +173,14 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
if (!driver.IsOpen)
|
if (!driver.IsOpen)
|
||||||
driver = null;
|
driver = null;
|
||||||
|
|
||||||
isaBusMutex = new Mutex(false, "Global\\Access_ISABUS.HTP.Method");
|
string mutexName = "Global\\Access_ISABUS.HTP.Method";
|
||||||
|
try {
|
||||||
|
isaBusMutex = new Mutex(false, mutexName);
|
||||||
|
} catch (UnauthorizedAccessException) {
|
||||||
|
try {
|
||||||
|
isaBusMutex = Mutex.OpenExisting(mutexName, MutexRights.Synchronize);
|
||||||
|
} catch { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsOpen {
|
public static bool IsOpen {
|
||||||
@@ -193,7 +201,10 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
|
|
||||||
driver = null;
|
driver = null;
|
||||||
|
|
||||||
|
if (isaBusMutex != null) {
|
||||||
isaBusMutex.Close();
|
isaBusMutex.Close();
|
||||||
|
isaBusMutex = null;
|
||||||
|
}
|
||||||
|
|
||||||
// try to delete temporary driver file again if failed during open
|
// try to delete temporary driver file again if failed during open
|
||||||
if (fileName != null && File.Exists(fileName)) {
|
if (fileName != null && File.Exists(fileName)) {
|
||||||
@@ -218,6 +229,8 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static bool WaitIsaBusMutex(int millisecondsTimeout) {
|
public static bool WaitIsaBusMutex(int millisecondsTimeout) {
|
||||||
|
if (isaBusMutex == null)
|
||||||
|
return true;
|
||||||
try {
|
try {
|
||||||
return isaBusMutex.WaitOne(millisecondsTimeout, false);
|
return isaBusMutex.WaitOne(millisecondsTimeout, false);
|
||||||
} catch (AbandonedMutexException) { return false; }
|
} catch (AbandonedMutexException) { return false; }
|
||||||
@@ -225,6 +238,8 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void ReleaseIsaBusMutex() {
|
public static void ReleaseIsaBusMutex() {
|
||||||
|
if (isaBusMutex == null)
|
||||||
|
return;
|
||||||
isaBusMutex.ReleaseMutex();
|
isaBusMutex.ReleaseMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user