Ejemplo n.º 1
0
        internal bool MarkUnreachable(RemoteHost remoteHost)
        {
            lock (_lock)
            {
                if (ReachableHosts.Remove(remoteHost))
                {
                    if (ReachableHosts.Count == 0)
                    {
                        ReachabilityBroadcaster.Post(new ServiceReachabilityStatus {
                            IsReachable = false
                        });
                    }
                    UnreachableHosts.Add(remoteHost);
                    return(true);
                }

                return(false);
            }
        }
Ejemplo n.º 2
0
        internal bool MarkReachable(RemoteHost remoteHost)
        {
            lock (_lock)
            {
                if (UnreachableHosts.Remove(remoteHost))
                {
                    ReachableHosts.Add(remoteHost);
                    if (ReachableHosts.Count == 1)
                    {
                        ReachabilityBroadcaster.Post(new ServiceReachabilityStatus {
                            IsReachable = true
                        });
                    }

                    FirstAvailableHostCompletionSource?.SetResult(remoteHost);
                    FirstAvailableHostCompletionSource = null;

                    return(true);
                }

                return(false);
            }
        }