Skip to content

Commit 9777946

Browse files
committed
Fix RemoveFrontend deadlock
1 parent ad2a6d4 commit 9777946

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Signal-Windows.Lib/SignalLibHandle.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ public bool AddFrontend(CoreDispatcher d, ISignalFrontend w)
147147
public void RemoveFrontend(CoreDispatcher d)
148148
{
149149
Logger.LogTrace("RemoveFrontend() locking");
150+
if (SynchronizationContext.Current != null)
151+
{
152+
Logger.LogCritical("RemoveFrontend must not be called with a syncchronization context");
153+
throw new InvalidOperationException();
154+
}
150155
SemaphoreSlim.Wait(CancelSource.Token);
151156
Logger.LogTrace("RemoveFrontend() locked");
152157
Logger.LogInformation("Unregistering frontend of dispatcher {0}", d.GetHashCode());

Signal-Windows/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ private void CurrView_Consolidated(ApplicationView sender, ApplicationViewConsol
357357
{
358358
sender.Consolidated -= CurrView_Consolidated;
359359
var signalWindowsFrontend = Views[sender.Id];
360-
Handle.RemoveFrontend(signalWindowsFrontend.Dispatcher);
360+
Task.Run(() => Handle.RemoveFrontend(signalWindowsFrontend.Dispatcher)).Wait();
361361
Views.Remove(sender.Id);
362362
if (sender.Id != MainViewId)
363363
{

0 commit comments

Comments
 (0)