V1/Toolbox.NETMF.Hardware.AutoRepeatInputPort/AutoRepeatInputPort.cs
/// <summary>
/// the working thread handler, as the manager of the auto-repeat
/// </summary>
the working thread handler, as the manager of the auto-repeat
the working thread handler as the manager of the auto - repeat
private void Worker()
        {
            bool prevActivity = false;
            int counter = 0;
            while (this._shutdown == false)
            {
                if (this.Read() == this.ActiveLevel)
                {
                    if (prevActivity)
                    {
                         in progress
                        if (--counter <= 0)
                        {
                            this.OnStateChanged(AutoRepeatState.Tick);
                            counter = this._autoRepeatPeriodCount;
                        }
                    }
                    else
                    {
                        this.OnStateChanged(AutoRepeatState.Press);
                        prevActivity = true;
                        counter = (this._initialDelayCount > 0)
                            ? this._initialDelayCount
                            : this._autoRepeatPeriodCount;
                    }
                }
                else if (prevActivity)
                {
                    this.OnStateChanged(AutoRepeatState.Release);
                    counter = 0;
                    prevActivity = false;
                }
                Thread.Sleep(QuantumDuration);
            }
        }
private void Worker ( ) { bool prevActivity = false ; int counter = 0 ; while ( this . _shutdown == false ) { if ( this . Read ( ) == this . ActiveLevel ) { if ( prevActivity ) { if ( -- counter <= 0 ) { this . OnStateChanged ( AutoRepeatState . Tick ) ; counter = this . _autoRepeatPeriodCount ; } } else { this . OnStateChanged ( AutoRepeatState . Press ) ; prevActivity = true ; counter = ( this . _initialDelayCount > 0 ) ? this . _initialDelayCount : this . _autoRepeatPeriodCount ; } } else if ( prevActivity ) { this . OnStateChanged ( AutoRepeatState . Release ) ; counter = 0 ; prevActivity = false ; } Thread . Sleep ( QuantumDuration ) ; } }
the working thread handler, as the manager of the auto-repeat
the working thread handler as the manager of the auto - repeat
//check the current level at the input port //activity //activity in progress //just pressed //just dropped into the inactivity //pause for the quantum duration