Created
September 27, 2018 22:42
-
-
Save kenanhancer/a0e67bb9099296d8b21af531533b67ed to your computer and use it in GitHub Desktop.
TaskBasedAsynchronousPattern_TAP created by kenanhancer - https://repl.it/@kenanhancer/TaskBasedAsynchronousPatternTAP
This file contains hidden or 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
using System; | |
using System.Threading.Tasks; | |
using System.Net; | |
class MainClass { | |
public static void Main (string[] args) { | |
MainAsync(args); | |
Console.WriteLine("Main thread is working."); | |
Console.ReadLine(); | |
} | |
public static async Task MainAsync(string[] args) | |
{ | |
IPHostEntry result = await CustomDnsWithTAP.GetHostEntryAsync("www.kenanhancer.com"); | |
Console.WriteLine($"Worker thread is working and result is {result.HostName}"); | |
} | |
} | |
public static class CustomDnsWithTAP | |
{ | |
public static Task<IPHostEntry> GetHostEntryAsync(string hostNameOrAddress) | |
{ | |
return Task.Run(() => Dns.GetHostEntry(hostNameOrAddress)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment