From e17a36f7cb65f2e61e1456992353ba09527fca50 Mon Sep 17 00:00:00 2001 From: Fre Date: Fri, 21 Aug 2020 12:13:38 +0200 Subject: [PATCH] small changes --- ElectronNET.API/App.cs | 35 ++++--------------- ElectronNET.API/AutoUpdater.cs | 17 ++++----- ElectronNET.API/Entities/ElectronException.cs | 28 --------------- ElectronNET.Host/api/autoUpdater.ts | 1 - 4 files changed, 13 insertions(+), 68 deletions(-) delete mode 100644 ElectronNET.API/Entities/ElectronException.cs diff --git a/ElectronNET.API/App.cs b/ElectronNET.API/App.cs index c59eb28..c388819 100644 --- a/ElectronNET.API/App.cs +++ b/ElectronNET.API/App.cs @@ -411,7 +411,7 @@ namespace ElectronNET.API [Obsolete("Use the asynchronous version NameAsync instead")] get { - return AsyncHelper.RunSync(async () => await NameAsync); + return NameAsync.Result; } set { @@ -448,29 +448,6 @@ namespace ElectronNET.API } } - /// - /// - /// - /// - public Task GetName() - - { - - var taskCompletionSource = new TaskCompletionSource(); - - BridgeConnector.Socket.On("appGetNameCompleted", (result) => - { - BridgeConnector.Socket.Off("appGetNameCompleted"); - taskCompletionSource.SetResult((string)result); - }); - - BridgeConnector.Socket.Emit("appGetName"); - - return taskCompletionSource.Task; - - } - - internal App() { @@ -1524,7 +1501,7 @@ namespace ElectronNET.API [Obsolete("Use the asynchronous version UserAgentFallbackAsync instead")] get { - return AsyncHelper.RunSync(async () => await UserAgentFallbackAsync); + return UserAgentFallbackAsync.Result; } set { @@ -1549,10 +1526,10 @@ namespace ElectronNET.API var taskCompletionSource = new TaskCompletionSource(); BridgeConnector.Socket.On("appGetUserAgentFallbackCompleted", (result) => - { - BridgeConnector.Socket.Off("appGetUserAgentFallbackCompleted"); - taskCompletionSource.SetResult((string)result); - }); + { + BridgeConnector.Socket.Off("appGetUserAgentFallbackCompleted"); + taskCompletionSource.SetResult((string)result); + }); BridgeConnector.Socket.Emit("appGetUserAgentFallback"); diff --git a/ElectronNET.API/AutoUpdater.cs b/ElectronNET.API/AutoUpdater.cs index 57ab1c6..da1001f 100644 --- a/ElectronNET.API/AutoUpdater.cs +++ b/ElectronNET.API/AutoUpdater.cs @@ -4,9 +4,6 @@ using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; using System; using System.Collections.Generic; -using System.Runtime.CompilerServices; -using System.Security.Cryptography.X509Certificates; -using System.Threading; using System.Threading.Tasks; namespace ElectronNET.API @@ -221,7 +218,7 @@ namespace ElectronNET.API { get { - return AsyncHelper.RunSync(async () => await ChannelAsync); + return ChannelAsync.Result; } } @@ -284,10 +281,10 @@ namespace ElectronNET.API } } - /// - /// Emitted when there is an error while updating. - /// - public event Action OnError + /// + /// Emitted when there is an error while updating. + /// + public event Action OnError { add { @@ -512,7 +509,7 @@ namespace ElectronNET.API string message = "An error occurred in CheckForUpdatesAsync"; if (error != null && !string.IsNullOrEmpty(error.ToString())) message = JsonConvert.SerializeObject(error); - taskCompletionSource.SetException(new ElectronException(message)); + taskCompletionSource.SetException(new Exception(message)); }); BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdates", guid); @@ -554,7 +551,7 @@ namespace ElectronNET.API string message = "An error occurred in autoUpdaterCheckForUpdatesAndNotify"; if (error != null) message = JsonConvert.SerializeObject(error); - taskCompletionSource.SetException(new ElectronException(message)); + taskCompletionSource.SetException(new Exception(message)); }); BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdatesAndNotify", guid); diff --git a/ElectronNET.API/Entities/ElectronException.cs b/ElectronNET.API/Entities/ElectronException.cs deleted file mode 100644 index 21e4555..0000000 --- a/ElectronNET.API/Entities/ElectronException.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; - -namespace ElectronNET.API.Entities -{ - /// - /// Electron Exception - /// - [Serializable] - public class ElectronException : Exception - { - /// - /// - /// - public ElectronException() - { - - } - - /// - /// - /// - /// - public ElectronException(string error) : base(error) - { - - } - } -} diff --git a/ElectronNET.Host/api/autoUpdater.ts b/ElectronNET.Host/api/autoUpdater.ts index 4e26d2b..79a92f8 100644 --- a/ElectronNET.Host/api/autoUpdater.ts +++ b/ElectronNET.Host/api/autoUpdater.ts @@ -141,7 +141,6 @@ export = (socket: SocketIO.Socket) => { }); }); - socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => { autoUpdater.quitAndInstall(isSilent, isForceRunAfter); });