Skip to content

Commit ca7414b

Browse files
Merge pull request #430 from freosc/master
HostHook.CallAsync should use TaskCompletionSource.SetException instead of throwing exception
2 parents 3420ee2 + 37ae869 commit ca7414b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ElectronNET.API/HostHook.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ public Task<T> CallAsync<T>(string socketEventName, params dynamic[] arguments)
7272
{
7373
BridgeConnector.Socket.Off(socketEventName + "Error" + guid);
7474
Electron.Dialog.ShowErrorBox("Host Hook Exception", result.ToString());
75+
taskCompletionSource.SetException(new Exception($"Host Hook Exception {result}"));
7576
});
7677

7778
BridgeConnector.Socket.On(socketEventName + "Complete" + guid, (result) =>
7879
{
7980
BridgeConnector.Socket.Off(socketEventName + "Error" + guid);
8081
BridgeConnector.Socket.Off(socketEventName + "Complete" + guid);
81-
T data;
82+
T data = default;
8283

8384
try
8485
{
@@ -105,7 +106,8 @@ public Task<T> CallAsync<T>(string socketEventName, params dynamic[] arguments)
105106
}
106107
catch (Exception exception)
107108
{
108-
throw new InvalidCastException("Return value does not match with the generic type.", exception);
109+
taskCompletionSource.SetException(exception);
110+
//throw new InvalidCastException("Return value does not match with the generic type.", exception);
109111
}
110112

111113
taskCompletionSource.SetResult(data);

0 commit comments

Comments
 (0)