mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-09 02:07:47 +00:00
fix race condition causing unobserved exception
This commit is contained in:
@@ -458,8 +458,23 @@ namespace ElectronNET.API
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await socket.ConnectAsync();
|
||||
_connectedSocketTask.TrySetResult(socket); //Probably was already on the OnConnected call
|
||||
try
|
||||
{
|
||||
if (!socket.Connected)
|
||||
{
|
||||
await socket.ConnectAsync();
|
||||
_connectedSocketTask.TrySetResult(socket); //Probably was already on the OnConnected call
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
if (!socket.Connected)
|
||||
{
|
||||
LogError(e, "Failed to connect");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_socket = socket;
|
||||
|
||||
Reference in New Issue
Block a user