Skip to content
Permalink
Browse files

Fixed stack trace being lost in EndInvoke and potentially throwing on…

… valid outputs
  • Loading branch information
ManlyMarco committed Nov 26, 2019
1 parent 5c7e1a2 commit 6cd69ea5a3ac231e43a3ab051cbc0e58ceb13286
Showing with 3 additions and 2 deletions.
  1. +3 −2 BepInEx/ThreadingHelper.cs
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Threading;
using BepInEx.Logging;
using UnityEngine;
@@ -118,7 +119,7 @@ IAsyncResult ISynchronizeInvoke.BeginInvoke(Delegate method, object[] args)
object Invoke()
{
try { return method.DynamicInvoke(args); }
catch (Exception ex) { return ex; }
catch (Exception ex) { return new TargetInvocationException(ex); }
}

var result = new InvokeResult();
@@ -135,7 +136,7 @@ object ISynchronizeInvoke.EndInvoke(IAsyncResult result)
{
result.AsyncWaitHandle.WaitOne();

if (result.AsyncState is Exception ex)
if (result.AsyncState is TargetInvocationException ex)
throw ex;
return result.AsyncState;
}

0 comments on commit 6cd69ea

Please sign in to comment.
You can’t perform that action at this time.