public static async Task<bool> CallSensorcoreApiAsync(Func<Task> action)
{
    Exception failure = null;
    try
    {
        await action();
    }
    catch (Exception e)
    {
        failure = e;
    }
    // Vrifie s'il y a eu une erreur
    if (failure != null)
    {
        MessageDialog dialog;
        switch (SenseHelper.GetSenseError(failure.HResult))
        {
            case SenseError.LocationDisabled: 
                // Location est dsactiv, demandons  l'utilisateur si il veut l'activer
                dialog = new MessageDialog("Location has been disabled. Do you want to open Location settings now?", "Information");
                dialog.Commands.Add(new UICommand("Yes", async cmd => await SenseHelper.LaunchLocationSettingsAsync()));
                dialog.Commands.Add(new UICommand("No"));
                await dialog.ShowAsync();
                new System.Threading.ManualResetEvent(false).WaitOne(500);
                return false;

            case SenseError.SenseDisabled:
		// Motion est dsactiv, demandons  l'utilisateur si il veut l'activer
                dialog = new MessageDialog("Motion data has been disabled. Do you want to open Motion data settings now?", "Information");
                dialog.Commands.Add(new UICommand("Yes", async cmd => await SenseHelper.LaunchSenseSettingsAsync()));
                dialog.Commands.Add(new UICommand("No"));
                await dialog.ShowAsync();
                new System.Threading.ManualResetEvent(false).WaitOne(500);
                return false;

            default:
                // Autre erreur
                dialog = new MessageDialog("Failure: " + SenseHelper.GetSenseError(failure.HResult), "");
                await dialog.ShowAsync();
                return false;
        }
    }

    return true;
}

private static async Task CreateMessageDialog(string message, string title, string label, UICommandInvokedHandler command, bool no)
{
    var dialog = new MessageDialog(message, title);
    dialog.Commands.Add(new UICommand(label, command));
    if (no) dialog.Commands.Add(new UICommand("No"));

    await dialog.ShowAsync();
}