I have programmed an application in Windows Form Application in Visual Studio, and I have already set a timer in my form which will check whether the user has access to the internet or not every 1 second (1000 ms), and if he/she does not have access, a form will pop up and shows that the user does not have access to the internet. This used to work very well until I have found out that the form will be poped out even when the internet shows a timeout, although I wanted to check if the user loses his/her access to the internet completely. I decided to work on another algorithm, and I want the timer to check if the internet has 5 timeouts in a row, and if it does, the form, which shows the user that they do not have access to the internet, pops up. Any specific idea about the mentioned plan? Here is my code in which it shows that the user has access to the internet or not. * LIC is the form which shows that the user does not have access to the internet* Method in the class
public static bool Check_Internet_For_Acceptation()
{
if (Connections.InternetConnection("google.com") == false)
{
return false;
}
else
return true;
}
And you can see the code that I have typed in the timer_Tick
private void TimerCheckInternetConnection_Tick(object sender, EventArgs e)
{
#region Check whether the users have internet connection or not
if (Components.Check_Internet_For_Acceptation() == false)
{
if (LIC.Visible)
{
LIC.Show();
return;
}
else
LIC.ShowDialog();
TimerCheckInternetConnection.Enabled = false;
}
#endregion
}