public static async Task StartConnectionAsync(LoginObject loginInfor) { try { _connection = new WSConnectionNew(Constants.ServerAddress); await _connection.StartConnectionAsync(loginInfor); } catch { } }
void bgwConnectWSl_DoWork(object sender, DoWorkEventArgs e) { try { while ((_connection == null) || (!_connection.Connected)) { _connection = new WSConnectionNew(Constants.ServerAddress); _connection.OnFileMessage += _connection_OnFileMessage; _connection.OnMessage += _connection_OnMessage; DisplayStatusMessage(DisplayMessages.TryingConnectToServer); StartConnectionAsync(); System.Threading.Thread.Sleep(10000); } } catch (Exception ex) { //MessageBox.Show("Cannot connect to server", "Connect to server error", MessageBoxButton.OK); } }