I am currently working on an WinForm Application, we are currently using Surface Pros to run the application. However, the application freezes up when it loses WiFi. I want to bring a warning message when the surface loses wifi.
And another message when it finds connection again
I have tried using an AddressChangedCallBack event.. however everytime I lose wifi nothing happens.
below is my piece of code
static void AddressChangedCallback(object sender, EventArgs e)
{
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface n in adapters)
{
string _name = n.Name;
OperationalStatus _operationalStatus = n.OperationalStatus;
if (_name.Contains("WiFi"))
{
if (_operationalStatus == OperationalStatus.Down)
{
FriendlyMessageBox.Show("Sorry - network has lost connection"
+ Environment.NewLine
+ Environment.NewLine
+ "You will lose your work if you close EIS"
, MessageBoxButtons.OK
, FriendlyMessageBox.FriendlyMessageBoxStyle.Warning
, "System Offline");
//notification timer use
}
else if (_operationalStatus == OperationalStatus.Up)
{
FriendlyMessageBox.Show("Connection Found"
+ Environment.NewLine
+ Environment.NewLine
+ "Please continue on your work"
, MessageBoxButtons.OK
, FriendlyMessageBox.FriendlyMessageBoxStyle.Success
, "System Connected");
//notification timer use
}
else
{
//notification timer use
}
any help would be greatly appreciated!