473,750 Members | 2,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NetworkAvailabi lity 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.Netw orkAvailability Changed.
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 NetworkAddressC hanged, 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 InitializeCompo nent(). (Note: It
doesn't work if I move it to the load event either.)

updateNetworkSt atus(NetworkInt erface.GetIsNet workAvailable() );
NetworkChange.N etworkAvailabil ityChanged +=
new
NetworkAvailabi lityChangedEven tHandler(myNetw orkAvailability ChangedHandler) ;

And here's my event handler:

private void myNetworkAvaila bilityChangedHa ndler(object sender,
NetworkAvailabi lityEventArgs args)
{
updateNetworkSt atus(args.IsAva ilable);
}

And here's the last method:

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

this.Invoke(new WaitCallback(up dateNetworkStat us), args.IsAvailabl e);

instead of just calling updateNetworkSt atus.

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 1368

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

Similar topics

6
5333
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
3895
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 response.write on its click handler but it won't fire either telling me no button click events will fire. But my calendar control on the same page does fire. In the debugger I put a break point in the calendar event and the button
3
3156
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. I get the postback but I never have the event called. It works fine in i.e.
2
8358
by: Breeto | last post by:
Can anyone please tell me why the following doesn't work... using System; using System.Web; namespace AspTests {
0
1854
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 child form implements an event handler for the Resize event. Inside BaseApplicationForm.InitializeComponent, this.ClientSize is set to a value. On most of our developers' machines, this.ClientSize = ....; does NOT fire the Resize event, which makes...
9
2471
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 post event will always execuate after the system is completed... - I want to wrap this functionality in a framework, so I could possibly have 3 or 4 levels of inherited objects that need to have these pre / post events executed before and after the...
19
4756
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 DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
5
3268
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 to it, and it doesn't work. I think I understand why, however, I would like to know if there is anything that I can bind to my variable that will fire the specified function whenever the value changes.
0
268
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. 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
0
9584
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9397
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9257
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8264
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6810
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4716
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.