Last active
December 24, 2015 07:19
-
-
Save prashantvc/6762841 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Task<int> ShowModalAletViewAsync (string title, string message, params string[] buttons) | |
{ | |
var alertView = new UIAlertView (title, message, null, null, buttons); | |
alertView.Show (); | |
var tsc = new TaskCompletionSource<int> (); | |
alertView.Clicked += (sender, buttonArgs) => { | |
Console.WriteLine ("User clicked on {0}", buttonArgs.ButtonIndex); | |
tsc.TrySetResult(buttonArgs.ButtonIndex); | |
}; | |
return tsc.Task; | |
} | |
//Usage | |
async Task PromptUser() { | |
var result = await ShowModalAletViewAsync ("Alert", "Do you want to continue?", "Yes", "No"); | |
//process the result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment