Merge pull request #1966 from Soreepeong/fix/servicescope

ServiceScope fixes
This commit is contained in:
goat 2024-07-25 21:30:14 +02:00 committed by GitHub
commit 8c593bc31d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 165 additions and 166 deletions

View file

@ -417,24 +417,16 @@ internal class LocalPlugin : IDisposable
try
{
if (this.manifest.LoadSync && this.manifest.LoadRequiredState is 0 or 1)
{
var newInstance = await framework.RunOnFrameworkThread(
() => this.ServiceScope.CreateAsync(
this.pluginType!,
this.DalamudInterface!)).ConfigureAwait(false);
this.instance = newInstance as IDalamudPlugin;
}
else
{
this.instance =
await this.ServiceScope.CreateAsync(this.pluginType!, this.DalamudInterface!) as IDalamudPlugin;
}
var forceFrameworkThread = this.manifest.LoadSync && this.manifest.LoadRequiredState is 0 or 1;
var newInstanceTask = forceFrameworkThread ? framework.RunOnFrameworkThread(Create) : Create();
this.instance = await newInstanceTask.ConfigureAwait(false);
async Task<IDalamudPlugin> Create() =>
(IDalamudPlugin)await this.ServiceScope!.CreateAsync(this.pluginType!, this.DalamudInterface!);
}
catch (Exception ex)
{
Log.Error(ex, "Exception in plugin constructor");
Log.Error(ex, "Exception during plugin initialization");
this.instance = null;
}