I have a click event which causes the phone to vibrate once a button is clicked. This generally works great, except sometimes the vibration doesnt stop until I completely close
You can use asynchrony to prevent blocking the UI. Rather than actually blocking the UI thread you need to schedule an action to happen again 100ms from now. Adding a continutation to a Task.Delay
call can do just that:
void newButton_Click(object sender, EventArgs e)
{
Action navigate = () =>
this.NavigationService.Navigate(new uri("/NewPage.xaml", UriKind.Relate));
if (Settings.EnableVibration.Value) //boolean flag to tell whether to vibrate or not
{
VibrateController.Default.Start();
Task.Delay(100).ContinueWith(t =>
{
VibrationController.Default.Stop();
navigate();
});
}
else
navigate();
}