C
coolram4u
Guest
Hi All,
Iam really upto a challenging task in windows app using vs2008 with c#. i want to first explain you in detail where iam using ISNetworkAvailable() method currently is NetworkChange.NetworkAvailabilityChanged method as the event fires when a user disconnects his laptop from ethernet cable and try to coonect using USB or Wireless which helps in recognising the events. But as the NetworkChange.NetworkAvailabilityChanged is not firing when multiple NICs are on, which is where i stuckup. I tried with NetworkChange.NetworkAddressChanged event which fires regularly but it fires multiple times which is another problem. can we make it to fire only once?
Please do find the code below and Can you suggest any better solution or better way to come out of this. Waiting eagerly for your reply.
using System.Net.NetworkInformation;
namespace NetworkTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);
}
private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
{
if (e.IsAvailable)
MessageBox.Show("Network connected!");
else
MessageBox.Show("Network disconnected!");
}
private void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
{
if (e.IsAvailable)
MessageBox.Show("Network connected!");
else
MessageBox.Show("Network disconnected!");
}
}
}
Thanks,
Ram
ram
Continue reading...
Iam really upto a challenging task in windows app using vs2008 with c#. i want to first explain you in detail where iam using ISNetworkAvailable() method currently is NetworkChange.NetworkAvailabilityChanged method as the event fires when a user disconnects his laptop from ethernet cable and try to coonect using USB or Wireless which helps in recognising the events. But as the NetworkChange.NetworkAvailabilityChanged is not firing when multiple NICs are on, which is where i stuckup. I tried with NetworkChange.NetworkAddressChanged event which fires regularly but it fires multiple times which is another problem. can we make it to fire only once?
Please do find the code below and Can you suggest any better solution or better way to come out of this. Waiting eagerly for your reply.
using System.Net.NetworkInformation;
namespace NetworkTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);
}
private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
{
if (e.IsAvailable)
MessageBox.Show("Network connected!");
else
MessageBox.Show("Network disconnected!");
}
private void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
{
if (e.IsAvailable)
MessageBox.Show("Network connected!");
else
MessageBox.Show("Network disconnected!");
}
}
}
Thanks,
Ram
ram
Continue reading...