Accelerometer _accelerometer; int _shakeCount = 0; public MainPage() { this.InitializeComponent(); _accelerometer=Accelerometer.GetDefault(); if (_accelerometer != null) _accelerometer.Shaken += new TypedEventHandler<Accelerometer, AccelerometerShakenEventArgs>(Shaken); } async private void Shaken(object sender, AccelerometerShakenEventArgs e) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { _shakeCount++; }); if (_shakeCount >= 3) { //method call _shakeCount = 0; } }
Don't know if it works?