Xam.Plugins.ManageSleep icon indicating copy to clipboard operation
Xam.Plugins.ManageSleep copied to clipboard

Could use a DoWithoutSleepAsync with a Func<task> parameter

Open keith-at-work opened this issue 6 years ago • 0 comments

This overload makes it easier to simply write anonymous async lambda methods like this:

await _sleepMode.DoWithoutSleepAsync(async () =>
{
    await DoSomeStuffAsync();
    await DoMoreStuffAsync();
});

New method:

public async Task DoWithoutSleepAsync(Func<Task> func)
{
    try
    {
        ActivateAutoSleepMode(false);
        await func();
    }
    finally
    {
        ActivateAutoSleepMode(true);
    }
}

keith-at-work avatar Feb 28 '18 00:02 keith-at-work