private void OnRotaryChanged(Object sender, RotaryChangeEventArgs e) { if (this.WaitingTask != null) { this.CancelTask(); } switch (e.RotaryChangeEventType) { case RotaryChangeEventType.SwitchPressed: this.Write("Pressed"); break; case RotaryChangeEventType.SwitchReleased: this.Write("Released"); break; case RotaryChangeEventType.TurnedLeft: this.Write("Previous"); break; case RotaryChangeEventType.TurnedRight: this.Write("Next"); break; default: this.Write(); break; } this.CancellationTokenSource = new CancellationTokenSource(); this.CancellationToken = this.CancellationTokenSource.Token; this.WaitingTask = Task.Delay(new TimeSpan(0, 0, 1)).ContinueWith(c => { this.Write(); this.CancelTask(); }, this.CancellationToken); }
private void OnChanged(RotaryChangeEventArgs e) { RotaryChangedHandler handler = this.RotaryChangedEvent; if (handler != null) { handler(this, e); } }