472,958 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

NetworkAvailability event won't fire or handler isn't seeing it


My application needs to know when the network availability has changed and
do some stuff when it does.

I wrote a small WinForms app to test System.Net.NetworkAvailabilityChanged.
It works great.

I put the same logic in my main application, and the event is never caught
by my handler.

If I put in NetworkAddressChanged, it *is* fired and caught. But I don't
need to know if the address changed, I need to know if the user is online or
not.

Here's my code:

In the constructor of my main form after InitializeComponent(). (Note: It
doesn't work if I move it to the load event either.)

updateNetworkStatus(NetworkInterface.GetIsNetworkA vailable());
NetworkChange.NetworkAvailabilityChanged +=
new
NetworkAvailabilityChangedEventHandler(myNetworkAv ailabilityChangedHandler);

And here's my event handler:

private void myNetworkAvailabilityChangedHandler(object sender,
NetworkAvailabilityEventArgs args)
{
updateNetworkStatus(args.IsAvailable);
}

And here's the last method:

private void updateNetworkStatus(object state)
{
//do stuff
System.Diagnostics.Debug.Print("***Network status changed to {0}.***",
state.ToString());
}
One blog I found recommended this in the event handler:

this.Invoke(new WaitCallback(updateNetworkStatus), args.IsAvailable);

instead of just calling updateNetworkStatus.

That doesn't work either, and I'm not sure why I would use that over just
calling it.

Any help or advice would be greatly appreciated.

Thanks,
RobinS.
GoldMail.com

Apr 11 '08 #1
0 1299

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tom | last post by:
Hi, In the following code I have reproduced a problem in IE that is extremely annoying for my application. <html> <head> <script type="text/javascript">
2
by: Sam Miller | last post by:
Hi, I have a button event that won't fire. I left it on Friday and it worked fine. I came back in on Monday and it won't fire. I tried putting another button and just putting a...
3
by: jeff29_b | last post by:
I am having a strange problem on a web form. I have an image button with an OnClick event handler. When I click the image the event isn't being called in the code behind when browsing in firefox....
2
by: Breeto | last post by:
Can anyone please tell me why the following doesn't work... using System; using System.Web; namespace AspTests {
0
by: Patrick Lioi | last post by:
We have form that is used as the base class of all of our forms, let's call it BaseApplicationForm. We have another form, say ChildApplicationForm that inherits from BaseApplicationForm. The...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
19
by: Daniela Roman | last post by:
Hello, I try to fire an event under a button click event and maybe anybody can give a clue please. I have let's say a WEB grid with PageIndexChanged event: private void...
5
by: Daz | last post by:
Hi everyone. Another simple question which should hopefully warrent a simple answer. I would like a function to be run whenever a variable is updated. I have tried binding the onchange event...
0
by: RobinS | last post by:
My application needs to know when the network availability has changed and do some stuff when it does. I wrote a small WinForms app to test System.Net.NetworkAvailabilityChanged. It works great....
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.