Пример #1
0
        public Controller(IMinerCommunication minnerCommunication, TimeSpan watchDogPollingPeriod)
        {
            this.minerComms = minnerCommunication;

            // bubble up events from IMinerCommunication
            this.minerComms.Message   += (s, e) => { this.Message(s, e); };
            this.minerComms.Connected += (s, e) => { this.OnConnected(); };

            this.watchDogPollingPeriod = watchDogPollingPeriod;

            // need to balance this speed between the mining process being able to start in this time and also having the app detect the initial connected status in a reasonable amount of time
            // so far, it seems that at giving it 5 seconds (since the minimum polling period is 10) is working well
            // if it's too fast, it will spawn an extra mining process
            this.watchDogPollingPeriodDisconnected = TimeSpan.FromTicks(watchDogPollingPeriod.Ticks / 2);

            this.watchdogTimer          = new DispatcherTimer();
            this.watchdogTimer.Tick    += watchdogTimer_Tick;
            this.watchdogTimer.Interval = watchDogPollingPeriodDisconnected;
            this.watchdogTimer.Start();
        }
Пример #2
0
        public Controller(IMinerCommunication minnerCommunication, TimeSpan watchDogPollingPeriod)
        {   
            this.minerComms = minnerCommunication;

            // bubble up events from IMinerCommunication
            this.minerComms.Message += (s, e) => { this.Message(s, e); }; 
            this.minerComms.Connected += (s, e) => { this.OnConnected(); };

            this.watchDogPollingPeriod = watchDogPollingPeriod;

            // need to balance this speed between the mining process being able to start in this time and also having the app detect the initial connected status in a reasonable amount of time
            // so far, it seems that at giving it 5 seconds (since the minimum polling period is 10) is working well
            // if it's too fast, it will spawn an extra mining process
            this.watchDogPollingPeriodDisconnected = TimeSpan.FromTicks(watchDogPollingPeriod.Ticks / 2);

            this.watchdogTimer = new DispatcherTimer();
            this.watchdogTimer.Tick += watchdogTimer_Tick;
            this.watchdogTimer.Interval = watchDogPollingPeriodDisconnected;
            this.watchdogTimer.Start();
        }