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);

View File

@@ -118,7 +118,7 @@ function startSplashScreen() {
let imageFile = path.join(currentBinPath, manifestJsonFile.splashscreen.imageFile);
imageSize(imageFile, (error, dimensions) => {
if (error) {
console.log(`load splashscreen error:`);
console.log('load splashscreen error:');
console.error(error);
throw new Error(error.message);
@@ -136,13 +136,29 @@ function startSplashScreen() {
alwaysOnTop: true,
show: true
});
if (manifestJsonFile.hasOwnProperty('splashscreen')) {
if (manifestJsonFile.splashscreen.hasOwnProperty('timeout')) {
var timeout = manifestJsonFile.splashscreen.timeout;
window.setTimeout((t) => {
if (splashScreen != null ) {
splashScreen.destroy();
splashScreen = null;
}
}, timeout);
}
}
splashScreen.setIgnoreMouseEvents(true);
app.once('browser-window-created', () => {
splashScreen.destroy();
splashScreen = null;
});
const loadSplashscreenUrl = path.join(__dirname, 'splashscreen', 'index.html') + '?imgPath=' + imageFile;
splashScreen.loadURL('file://' + loadSplashscreenUrl);
splashScreen.once('closed', () => {