small changes

This commit is contained in:
Fre
2020-08-21 12:13:38 +02:00
parent deccebb582
commit e17a36f7cb
4 changed files with 13 additions and 68 deletions

View File

@@ -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
}
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public Task<string> GetName()
{
var taskCompletionSource = new TaskCompletionSource<string>();
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<string>();
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");

View File

@@ -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
}
}
/// <summary>
/// Emitted when there is an error while updating.
/// </summary>
public event Action<string> OnError
/// <summary>
/// Emitted when there is an error while updating.
/// </summary>
public event Action<string> 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);

View File

@@ -1,28 +0,0 @@
using System;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Electron Exception
/// </summary>
[Serializable]
public class ElectronException : Exception
{
/// <summary>
///
/// </summary>
public ElectronException()
{
}
/// <summary>
///
/// </summary>
/// <param name="error"></param>
public ElectronException(string error) : base(error)
{
}
}
}