From 34a51d0119fc9403280781e5066f21dd17c9b852 Mon Sep 17 00:00:00 2001 From: goat Date: Mon, 8 Jul 2024 19:21:44 +0200 Subject: [PATCH] pm: make sure that we don't stay on framework thread when loading and unloading Without ConfigureAwait(false), all of the continuations below the await will be blocking the main thread --- Dalamud/Plugin/Internal/Types/LocalPlugin.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs index 4bc2add70..f7bb3495c 100644 --- a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs @@ -419,10 +419,12 @@ internal class LocalPlugin : IDisposable { if (this.manifest.LoadSync && this.manifest.LoadRequiredState is 0 or 1) { - this.instance = await framework.RunOnFrameworkThread( + var newInstance = await framework.RunOnFrameworkThread( () => this.ServiceScope.CreateAsync( this.pluginType!, - this.DalamudInterface!)) as IDalamudPlugin; + this.DalamudInterface!)).ConfigureAwait(false); + + this.instance = newInstance as IDalamudPlugin; } else { @@ -512,7 +514,7 @@ internal class LocalPlugin : IDisposable if (this.manifest.CanUnloadAsync || framework == null) this.instance?.Dispose(); else - await framework.RunOnFrameworkThread(() => this.instance?.Dispose()); + await framework.RunOnFrameworkThread(() => this.instance?.Dispose()).ConfigureAwait(false); } catch (Exception e) {