
static void Main(string[] args)
{
MainAsync().Wait();
}static async Task MainAsync()
{
Task.Run(() => CheckNet());
Task.Run(() => Runwo());
Console.ReadLine();
}
//check internet
public static bool PingTest()
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();System.Net.NetworkInformation.PingReply pingStatus =
ping.Send(IPAddress.Parse("208.69.34.231"), 1000);if (pingStatus.Status == System.Net.NetworkInformation.IPStatus.Success)
{
return true;
}
else
{
return false;
}
}//print net discoect
public static async Task CheckNet()
{
if (!PingTest())
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("No Internet :(");
Console.WriteLine("the App Restart Ofter 2 Seconds :(");
System.Threading.Thread.Sleep(2000);
ResetMe();}
}
//restart app
static void ResetMe()
{
var fileName = Assembly.GetExecutingAssembly().Location;
System.Diagnostics.Process.Start(fileName);
Environment.Exit(0);
}
public static async Task Runwo()
{
//get internet data
}
برچسب:
نویسنده: محمد رضا جوادیان