mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Isolate plugin constructors to separate threads
This commit is contained in:
parent
8ca473839a
commit
d16e783466
1 changed files with 21 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ using System.Diagnostics;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Logging.Internal;
|
||||
|
|
@ -127,7 +128,26 @@ internal class ServiceContainer : IServiceProvider, IServiceType
|
|||
return null;
|
||||
}
|
||||
|
||||
ctor.Invoke(instance, resolvedParams);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var thr = new Thread(
|
||||
() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ctor.Invoke(instance, resolvedParams);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
tcs.SetException(e);
|
||||
return;
|
||||
}
|
||||
|
||||
tcs.SetResult();
|
||||
});
|
||||
|
||||
thr.Start();
|
||||
await tcs.Task.ConfigureAwait(false);
|
||||
thr.Join();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue