mirror of
https://github.com/Radarr/Radarr
synced 2025-02-27 08:33:21 +00:00
Fixed mono fix by checking if the Enum value exists in the runtime.
This commit is contained in:
parent
5b5cc48549
commit
052a3bf47e
1 changed files with 12 additions and 5 deletions
|
@ -81,11 +81,18 @@ public Command PublishCommandAsync<TCommand>(TCommand command) where TCommand :
|
||||||
// For now we use TaskCreationOptions 0x10, which is actually .net 4.5 HideScheduler.
|
// For now we use TaskCreationOptions 0x10, which is actually .net 4.5 HideScheduler.
|
||||||
// This will detach the scheduler from the thread, causing new Task creating in the command to be executed on the ThreadPool, avoiding a deadlock.
|
// This will detach the scheduler from the thread, causing new Task creating in the command to be executed on the ThreadPool, avoiding a deadlock.
|
||||||
// Please note that the issue only shows itself on mono because since Microsoft .net implementation supports Task inlining on WaitAll.
|
// Please note that the issue only shows itself on mono because since Microsoft .net implementation supports Task inlining on WaitAll.
|
||||||
_taskFactory.StartNew(() => ExecuteCommand<TCommand>(command)
|
if (Enum.IsDefined(typeof(TaskCreationOptions), (TaskCreationOptions)0x10))
|
||||||
, TaskCreationOptions.PreferFairness)
|
{
|
||||||
// This breaks on systems that don't have .Net 4.5 installed (but works fine when it does, even though we are targetting 4.0)
|
_taskFactory.StartNew(() => ExecuteCommand<TCommand>(command)
|
||||||
// , TaskCreationOptions.PreferFairness | (TaskCreationOptions)0x10)
|
, TaskCreationOptions.PreferFairness | (TaskCreationOptions)0x10)
|
||||||
.LogExceptions();
|
.LogExceptions();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_taskFactory.StartNew(() => ExecuteCommand<TCommand>(command)
|
||||||
|
, TaskCreationOptions.PreferFairness)
|
||||||
|
.LogExceptions();
|
||||||
|
}
|
||||||
|
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue