mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Made use of the global mutex, this should now hopefully work #2750
This commit is contained in:
parent
1322076aa6
commit
947c0e74cb
3 changed files with 11 additions and 14 deletions
|
@ -1,15 +1,16 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Nito.AsyncEx;
|
||||
|
||||
namespace Ombi.Helpers
|
||||
{
|
||||
public static class GlobalMutex
|
||||
{
|
||||
public static T Lock<T>(Func<T> func)
|
||||
public static async Task<T> Lock<T>(Func<Task<T>> func)
|
||||
{
|
||||
const string mutexId = "Global\\OMBI";
|
||||
|
||||
using (var mutex = new Mutex(false, mutexId, out __))
|
||||
using (var mutex = new Mutex(false, mutexId, out _))
|
||||
{
|
||||
var hasHandle = false;
|
||||
try
|
||||
|
@ -25,7 +26,7 @@ namespace Ombi.Helpers
|
|||
hasHandle = true;
|
||||
}
|
||||
|
||||
return func();
|
||||
return await func();
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue