예제 #1
0
 private async void NetworkClient_OnDisconnected(object sender, Network.Events.DisconnectedEventArgs e)
 {
     IsConnected = false;
     while (!await AttemptConnectAsync(true))
     {
         await Task.Delay(1000);
     }
 }
예제 #2
0
        private void NetworkClient_OnDisconnected(object sender, Network.Events.DisconnectedEventArgs e)
        {
            lock (_connectedClients) {
                _connectedClients.Remove(sender as NetworkClient);
            }

            OnClientDisconnected?.Invoke(this, new ClientDisconnectedEventArgs(sender as NetworkClient));
        }
예제 #3
0
        private async void NetworkClient_OnDisconnected(object sender, Network.Events.DisconnectedEventArgs e)
        {
#pragma warning disable CS4014
            Task.Run(() => OnNetworkClientDisconnected?.Invoke(this, new DisconnectedEventArgs()));
#pragma warning restore CS4014

            IsConnected = false;

            try {
                while (!await AttemptConnectAsync(true))
                {
                    await Task.Delay(1000).WithCancellation(_clientCancellationToken.Token);
                }
            } catch (OperationCanceledException ex) {
                // Catch, consume, adapt, overcome
            }
        }