Skip to content

Commit bfd51e6

Browse files
committed
Fix dead-lock on shutdown
1 parent bb4337a commit bfd51e6

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/ElectronNET.AspNet/Runtime/Controllers/RuntimeControllerAspNetDotnetFirstSignalR.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,12 @@ private async void OnElectronHostReady()
163163

164164
private void SignalRFacade_Disconnected(object sender, EventArgs e)
165165
{
166-
this.HandleStopped();
166+
// IMPORTANT: Do NOT call HandleStopped synchronously here!
167+
// This event fires from within SignalR's OnDisconnectedAsync, and calling
168+
// StopApplication() synchronously causes a deadlock: the host waits for
169+
// OnDisconnectedAsync to complete, but we're waiting for the host to stop.
170+
// Fire and forget to break the deadlock.
171+
_ = Task.Run(() => this.HandleStopped());
167172
}
168173

169174
private void ElectronProcess_Stopped(object sender, EventArgs e)

0 commit comments

Comments
 (0)