mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
Hosthook.CallAsync<T> blocks execution when exception occurs inside #508
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @freosc on GitHub (Jun 7, 2020).
Originally assigned to: @GregorBiswanger on GitHub.
API and CLI 8.31.2
.net core 3.1, node 12.16.3
When using HostHook.CallAsync(), my call is blocked when an exception occurs inside the CallAsync method, and code after my CallAsync doesn't get executed.
I updated the on complete handler in your HostHook.CallAsync() code like this:
Which redirects the exception to the calling code, where I can catch it, and resolves this issue.
I guess the same "SetException" code should be used in the on error handler, to be sure that the code doesn't block the caller.
Steps to Reproduce:
The code above will block, unless the "taskCompletionSource.SetException(exception);" is used in the CallAsync() code.
In that case, I can catch the Exception that occurs (System.InvalidCastException: Unable to cast object of type 'System.Int64' to type 'System.Int32'.). There's no issue with the exception though, that's clear, I have to use a long instead of an int.
@GregorBiswanger commented on GitHub (Jun 11, 2020):
Would you like to submit a pull request to us? Electron.NET - Contributing Getting Started
@freosc commented on GitHub (Jun 12, 2020):
Sure