Example #1
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing && _throttledAction != null)
         {
             _throttledAction.Dispose();
             _throttledAction = null;
         }
         _disposed = true;
     }
 }
Example #2
0
        public ThrottledOperation(List <ServerBase> servers, IEnumerable <RdpClient.ConnectionState> completionStates, Action preAction, Action <ServerBase> action, int delayInMilliseconds, Action postAction)
        {
            _serversInScope   = new HashSet <Server>();
            _completionStates = new HashSet <RdpClient.ConnectionState>(completionStates);
            Action preAction2 = delegate
            {
                preAction();
                Server.ConnectionStateChanged += ConnectionStateChangeConnectHandler;
            };

            _throttledAction = new ThrottledAction(servers, preAction2, delegate(ServerBase server)
            {
                lock (_serversInScopeLock)
                {
                    _serversInScope.Add(server.ServerNode);
                }
                action(server);
            }, delayInMilliseconds, delegate
            {
                Server.ConnectionStateChanged -= ConnectionStateChangeConnectHandler;
                postAction();
            });
        }