Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@zs40x
Last active March 26, 2016 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zs40x/4181552307d2e8bb008a to your computer and use it in GitHub Desktop.
Save zs40x/4181552307d2e8bb008a to your computer and use it in GitHub Desktop.
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