question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What's about reworking MaterialDialogs.ShowAlertAsync to make it really awaitable and return Task<bool> instead?

See original GitHub issue

Hi!

I’ve tried also MaterialDialogs.ShowAlertAsync which works fine in general. However, with current implementation I can’t see a way of notifying when the alert (confirmation) box is closed with negative (cancelling) result.

Currently the method is (in general) awaitable, which completes on the confirm popup appearing, however, usually, it doesn’t have much sense from the app logic functionality perspective. From my experience, it’s rather more important to be able further processing of the app logic after the choice been done.

So, I would suggest to rework it to return Task<bool>, which would complete after the used made his choice.

What do you think? I can also fork and apply that update as well if you have no time for that.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
contrix09commented, Sep 3, 2018

I can also fix that. I set it to 40 since it was the recommended height, but I forgot to consider long titles.

BTW, thanks for raising these issues/suggestions.

0reactions
contrix09commented, Sep 5, 2018

Version 1.0.6 has been released, adding MaterialDialogs.ShowConfirmAsync() which returns Task<bool>. Also, the title of the alert dialog now breaks line when it is long.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async gotcha: returning Task.FromResult or ...
Because HandleAsync is actually synchronous, any exception propagates as soon as it's called, not when it's awaited. This is surprising to most ...
Read more >
Async method to return true or false in a Task
I know that an async method can only return void or Task . I have read similar methods for Exception handling inside async...
Read more >
Async return types (C#)
WaitAndApologizeAsync is awaited by using an await statement instead of an await expression, similar to the calling statement for a synchronous ...
Read more >
Is awaiting a Task instead of returning it directly in C# actually ...
Become a Patreon and get source code access: ... async and that's whether you should await a task or when possible returning it...
Read more >
What is the best way to return a Task<bool> in a async ...
You can do return Task.FromResult(false) (or you can just make the method async and simply return false).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found