Skip to content

Commit ca9bee7

Browse files
committed
Merge branch 'master' into switch-to-new-socket-lib
2 parents 8f71480 + 0aab352 commit ca9bee7

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

ElectronNET.API/App.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ public static void ManuallySetIsReady()
556556
/// </summary>
557557
public void Quit()
558558
{
559-
BridgeConnector.Emit("appQuit");
559+
BridgeConnector.EmitSync("appQuit");
560560
}
561561

562562
/// <summary>
@@ -566,7 +566,7 @@ public void Quit()
566566
/// <param name="exitCode">Exits immediately with exitCode. exitCode defaults to 0.</param>
567567
public void Exit(int exitCode = 0)
568568
{
569-
BridgeConnector.Emit("appExit", exitCode);
569+
BridgeConnector.EmitSync("appExit", exitCode);
570570
}
571571

572572
/// <summary>
@@ -581,7 +581,7 @@ public void Exit(int exitCode = 0)
581581
/// </summary>
582582
public void Relaunch()
583583
{
584-
BridgeConnector.Emit("appRelaunch");
584+
BridgeConnector.EmitSync("appRelaunch");
585585
}
586586

587587
/// <summary>
@@ -599,7 +599,7 @@ public void Relaunch()
599599
/// <param name="relaunchOptions">Options for the relaunch.</param>
600600
public void Relaunch(RelaunchOptions relaunchOptions)
601601
{
602-
BridgeConnector.Emit("appRelaunch", JObject.FromObject(relaunchOptions, _jsonSerializer));
602+
BridgeConnector.EmitSync("appRelaunch", JObject.FromObject(relaunchOptions, _jsonSerializer));
603603
}
604604

605605
/// <summary>
@@ -698,8 +698,7 @@ public async Task<string> GetPathAsync(PathName pathName, CancellationToken canc
698698

699699
BridgeConnector.Emit("appGetPath", pathName.GetDescription());
700700

701-
return await taskCompletionSource.Task
702-
.ConfigureAwait(false);
701+
return await taskCompletionSource.Task.ConfigureAwait(false);
703702
}
704703
}
705704

ElectronNET.API/AutoUpdater.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ public Task<UpdateCheckResult> CheckForUpdatesAndNotifyAsync()
539539
/// <param name="isForceRunAfter">Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`.</param>
540540
public void QuitAndInstall(bool isSilent = false, bool isForceRunAfter = false)
541541
{
542-
BridgeConnector.Emit("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter);
542+
BridgeConnector.EmitSync("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter);
543543
}
544544

545545
/// <summary>

ElectronNET.API/BridgeConnector.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ public static void Emit(string eventString, params object[] args)
8989

9090
Task.Run(async () =>
9191
{
92-
await Task.Yield();
9392
if (App.SocketDebug)
9493
{
9594
Console.WriteLine($"Sending event {eventString}");
@@ -104,6 +103,26 @@ public static void Emit(string eventString, params object[] args)
104103
});
105104
}
106105

106+
/// <summary>
107+
/// 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
108+
/// </summary>
109+
/// <param name="eventString"></param>
110+
/// <param name="args"></param>
111+
internal static void EmitSync(string eventString, params object[] args)
112+
{
113+
if (App.SocketDebug)
114+
{
115+
Console.WriteLine($"Sending event {eventString}");
116+
}
117+
118+
Socket.EmitAsync(eventString, args).Wait();
119+
120+
if (App.SocketDebug)
121+
{
122+
Console.WriteLine($"Sent event {eventString}");
123+
}
124+
}
125+
107126
public static void Off(string eventString)
108127
{
109128
Socket.Off(eventString);

ElectronNET.Host/main.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function startSplashScreen() {
118118
let imageFile = path.join(currentBinPath, manifestJsonFile.splashscreen.imageFile);
119119
imageSize(imageFile, (error, dimensions) => {
120120
if (error) {
121-
console.log(`load splashscreen error:`);
121+
console.log('load splashscreen error:');
122122
console.error(error);
123123

124124
throw new Error(error.message);
@@ -136,13 +136,29 @@ function startSplashScreen() {
136136
alwaysOnTop: true,
137137
show: true
138138
});
139+
140+
if (manifestJsonFile.hasOwnProperty('splashscreen')) {
141+
if (manifestJsonFile.splashscreen.hasOwnProperty('timeout')) {
142+
var timeout = manifestJsonFile.splashscreen.timeout;
143+
window.setTimeout((t) => {
144+
if (splashScreen != null ) {
145+
splashScreen.destroy();
146+
splashScreen = null;
147+
}
148+
}, timeout);
149+
}
150+
}
151+
152+
139153
splashScreen.setIgnoreMouseEvents(true);
140154

141155
app.once('browser-window-created', () => {
142156
splashScreen.destroy();
157+
splashScreen = null;
143158
});
144159

145160
const loadSplashscreenUrl = path.join(__dirname, 'splashscreen', 'index.html') + '?imgPath=' + imageFile;
161+
146162
splashScreen.loadURL('file://' + loadSplashscreenUrl);
147163

148164
splashScreen.once('closed', () => {

0 commit comments

Comments
 (0)