Merge branch 'master' into switch-to-new-socket-lib

This commit is contained in:
rafael-aero
2021-08-20 15:16:16 +02:00
4 changed files with 43 additions and 9 deletions

View File

@@ -556,7 +556,7 @@ namespace ElectronNET.API
/// </summary>
public void Quit()
{
BridgeConnector.Emit("appQuit");
BridgeConnector.EmitSync("appQuit");
}
/// <summary>
@@ -566,7 +566,7 @@ namespace ElectronNET.API
/// <param name="exitCode">Exits immediately with exitCode. exitCode defaults to 0.</param>
public void Exit(int exitCode = 0)
{
BridgeConnector.Emit("appExit", exitCode);
BridgeConnector.EmitSync("appExit", exitCode);
}
/// <summary>
@@ -581,7 +581,7 @@ namespace ElectronNET.API
/// </summary>
public void Relaunch()
{
BridgeConnector.Emit("appRelaunch");
BridgeConnector.EmitSync("appRelaunch");
}
/// <summary>
@@ -599,7 +599,7 @@ namespace ElectronNET.API
/// <param name="relaunchOptions">Options for the relaunch.</param>
public void Relaunch(RelaunchOptions relaunchOptions)
{
BridgeConnector.Emit("appRelaunch", JObject.FromObject(relaunchOptions, _jsonSerializer));
BridgeConnector.EmitSync("appRelaunch", JObject.FromObject(relaunchOptions, _jsonSerializer));
}
/// <summary>
@@ -698,8 +698,7 @@ namespace ElectronNET.API
BridgeConnector.Emit("appGetPath", pathName.GetDescription());
return await taskCompletionSource.Task
.ConfigureAwait(false);
return await taskCompletionSource.Task.ConfigureAwait(false);
}
}

View File

@@ -539,7 +539,7 @@ namespace ElectronNET.API
/// <param name="isForceRunAfter">Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`.</param>
public void QuitAndInstall(bool isSilent = false, bool isForceRunAfter = false)
{
BridgeConnector.Emit("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter);
BridgeConnector.EmitSync("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter);
}
/// <summary>

View File

@@ -89,7 +89,6 @@ namespace ElectronNET.API
Task.Run(async () =>
{
await Task.Yield();
if (App.SocketDebug)
{
Console.WriteLine($"Sending event {eventString}");
@@ -104,6 +103,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);