Fixed: Hangup on change connection while connected

This commit is contained in:
TheJoKlLa 2023-02-28 13:21:22 +01:00
parent 75da7b6534
commit 6b46303607
2 changed files with 8 additions and 11 deletions

View File

@ -111,17 +111,13 @@ namespace Borepin.PageModel.AddServerProcess
}, },
}; };
if (_API.IsConnected) try
{ {
if (_API.IsConnected) if (_API.IsConnecting || _API.IsConnected)
{ {
await _API.Disconnect().ConfigureAwait(true); await _API.Disconnect().ConfigureAwait(true);
_API.UnbindEventHandler(); _API.UnbindEventHandler();
} }
}
try
{
await _API.Connect(_ConnectionData).ConfigureAwait(false); await _API.Connect(_ConnectionData).ConfigureAwait(false);
} }
catch (Exception exception) catch (Exception exception)

View File

@ -133,13 +133,14 @@ namespace Borepin.PageModel
IsBusy = true; IsBusy = true;
TestConnection = true; TestConnection = true;
if (_API.IsConnected)
{
await _API.Disconnect().ConfigureAwait(true);
}
try try
{ {
if (_API.IsConnecting || _API.IsConnected)
{
await _API.Disconnect().ConfigureAwait(true);
_API.UnbindEventHandler();
}
await _API.Connect(Connection_Item).ConfigureAwait(false); await _API.Connect(Connection_Item).ConfigureAwait(false);
} }
catch(Exception exception) catch(Exception exception)