예제 #1
0
            private static void DelayAction(Session inSession, Action <Session> action, int?pollingInterval, Func <Session, bool> pollingSelector)
            {
                pollingSelector = pollingSelector ?? Selectors.Always();
                pollingInterval = pollingInterval ?? POLLING_INTERVAL;

                Timer delayTimer = new Timer()
                {
                    AutoReset = false,
                    Interval  = pollingInterval.Value
                };

                delayTimer.Elapsed += (sender, obj) =>
                {
                    if (pollingSelector(inSession))
                    {
                        delayTimer.Stop();
                        delayTimer.Dispose();
                        action(inSession);
                    }
                    else
                    {
                        delayTimer.Start();
                    }
                };

                delayTimer.Start();
            }