Last active
March 26, 2016 08:07
-
-
Save zs40x/4181552307d2e8bb008a 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
private async void DoWhoisLookup() | |
{ | |
EnableInput(false); | |
try | |
{ | |
var googleWhoisLookup = new WhoisLookup(tbHostToLookup.Text); | |
// initiate HTTP request asynchronously | |
Task<string> getWhoisInfoTask = googleWhoisLookup.GetWhoisInformationsAsync(); | |
// during the HTTP download we display this state in the GUI | |
DisplayMessageWithBgColor("Loading....", Color.Orange); | |
// now we wait untit the download is completed | |
var result = await getWhoisInfoTask; | |
// and display the content | |
DisplayMessageWithBgColor(result.Replace("\n", Environment.NewLine), Color.LightGreen); | |
} | |
catch (Exception exception) | |
{ | |
DisplayMessageWithBgColor(exception.Message, Color.LightCoral); | |
} | |
finally | |
{ | |
EnableInput(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment