Browse Source

Fixed disable tasks for .NET 3

pull/46/head
Anairkoen Schno 4 years ago
parent
commit
4a2d14559e
3 changed files with 25 additions and 1 deletions
  1. +2
    -1
      IPA.Loader/Loader/PluginManager.cs
  2. +1
    -0
      Net3-Proxy/Net3-Proxy.csproj
  3. +22
    -0
      Net3-Proxy/TaskEx6.cs

+ 2
- 1
IPA.Loader/Loader/PluginManager.cs View File

@ -15,6 +15,7 @@ using Logger = IPA.Logging.Logger;
using System.Threading.Tasks;
#if NET4
using TaskEx = System.Threading.Tasks.Task;
using TaskEx6 = System.Threading.Tasks.Task;
using Task = System.Threading.Tasks.Task;
#endif
#if NET3
@ -177,7 +178,7 @@ namespace IPA.Loader
else
{
if (exec.Executor.Metadata.RuntimeOptions != RuntimeOptions.DynamicInit)
return TaskEx.FromException(new CannotRuntimeDisableException(exec.Executor.Metadata));
return TaskEx6.FromException(new CannotRuntimeDisableException(exec.Executor.Metadata));
var res = TaskEx.WhenAll(exec.Dependents.Select(d => Disable(d, alreadyDisabled)))
.ContinueWith(t => TaskEx.WhenAll(t, exec.Executor.Disable())).Unwrap();


+ 1
- 0
Net3-Proxy/Net3-Proxy.csproj View File

@ -48,6 +48,7 @@
<Compile Include="IReadOnlyList.cs" />
<Compile Include="Path.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TaskEx6.cs" />
<Compile Include="Tuple.cs" />
<Compile Include="TypeUtils.cs" />
<Compile Include="Utils.cs" />


+ 22
- 0
Net3-Proxy/TaskEx6.cs View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Net3_Proxy
{
public static class TaskEx6
{
public static Task<TResult> FromException<TResult>(Exception exception)
{
if (exception == null) throw new ArgumentNullException(nameof(exception));
var tcs = new TaskCompletionSource<TResult>();
tcs.TrySetException(exception);
return tcs.Task;
}
public static Task FromException(Exception exception) => FromException<VoidTaskResult>(exception);
private struct VoidTaskResult { }
}
}

Loading…
Cancel
Save