add internal method to emit socket events synchronously, and use it for all exit, quit and relaunch methods

This commit is contained in:
rafael-aero
2021-08-20 15:06:58 +02:00
parent 9daaebcef6
commit a8229f2fa9
3 changed files with 26 additions and 7 deletions

View File

@@ -104,6 +104,26 @@ namespace ElectronNET.API
});
}
/// <summary>
/// This method is only used on places where we need to be sure the event was sent on the socket, such as Quit, Exit, Relaunch and QuitAndInstall methods
/// </summary>
/// <param name="eventString"></param>
/// <param name="args"></param>
internal static void EmitSync(string eventString, params object[] args)
{
if (App.SocketDebug)
{
Console.WriteLine($"Sending event {eventString}");
}
Socket.EmitAsync(eventString, args).Wait();
if (App.SocketDebug)
{
Console.WriteLine($"Sent event {eventString}");
}
}
public static void Off(string eventString)
{
Socket.Off(eventString);