473,799 Members | 3,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Network Availability detection

Hello everybody.

I want to make a little programme to show the network availability
status. I read that I had to use
Microsoft.Visua lBasic.Devices, creat a delegate to manage the event.

Here is the code that I made but of course it dosn't work

namespace WindowsApplicat ion2
{
public delegate void MyApplication_N etworkAvailabil ityChanged(obje ct
sender, Microsoft.Visua lBasic.Devices. NetworkAvailabl eEventArgs e);

partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.button1 = new System.Windows. Forms.Button();
this.label1 = new System.Windows. Forms.Label();
this.SuspendLay out();
//
// button1
//
this.button1.Lo cation = new System.Drawing. Point(92, 64);
this.button1.Na me = "button1";
this.button1.Si ze = new System.Drawing. Size(125, 62);
this.button1.Ta bIndex = 0;
this.button1.Te xt = "button1";
this.button1.Us eVisualStyleBac kColor = true;
//
// label1
//
this.label1.Aut oSize = true;
this.label1.Loc ation = new System.Drawing. Point(56, 185);
this.label1.Nam e = "label1";
this.label1.Siz e = new System.Drawing. Size(35, 13);
this.label1.Tab Index = 1;
this.label1.Tex t = "label1";
//
// Form1
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F, 13F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(292, 273);
this.Controls.A dd(this.label1) ;
this.Controls.A dd(this.button1 );
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);
this.PerformLay out();

//
// Network availability
//
this.netwatch = new NetworkWatching ();
this.netwatch.A vChange += new
MyApplication_N etworkAvailabil ityChanged(this .netwat_AvChang e);

}

#endregion

private System.Windows. Forms.Button button1;
private NetworkWatching netwatch;
private System.Windows. Forms.Label label1;
}

class NetworkWatching
{
public event MyApplication_N etworkAvailabil ityChanged AvChange;
}
}

this is in the Form1.Designer. cs

In the Form1.cs I added :

private void DisplayAvail(st ring avail)
{
label1.Text = avail;
}

void netwat_AvChange (object sender,
Microsoft.Visua lBasic.Devices. NetworkAvailabl eEventArgs e)
{
this.DisplayAva il(e.IsNetworkA vailable.ToStri ng());
}

Any idea what i have to do to make what i want ? I now that probably I
miss a conceptual clarification.

Anyway, thx a lot for the help

Aug 28 '07 #1
2 2532
Ok I went an other way, I try now to use the WMI api. I have to find
what is the event linked to network managment to make my query but It
seam's much easier

Aug 28 '07 #2
Folkejen, look up System.Net.Netw orkInformation. NetworkChange class. It
has two public events - NetworkAvailabi lityChanged and
NetworkAddressC hanged. C# help for NetworkAddressC hanged comes with code
fragment showing how to use this event. The other one can be handled in the
same manner.

Michael

"Folkien" <jo**********@h otmail.comwrote in message
news:11******** ************@o8 0g2000hse.googl egroups.com...
Ok I went an other way, I try now to use the WMI api. I have to find
what is the event linked to network managment to make my query but It
seam's much easier

Aug 28 '07 #3

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

Similar topics

1
3359
by: ripken95 | last post by:
I connect to the internet through ADSL. I want to write the web page which can detect the connection status with javascript. This detection is like the signal detection in the mobile phone. If the signal is weak, the status may have one squares or zero on the phone. How could I do if I want to detect the status of the network? Thx and Best Regards.
1
4325
by: Ghulam | last post by:
I am using an Access 2k ADP (Converted into ADE) front end and SQL 2K on the backend. Although I taught pretty much myself into these concept with the help of some publications and users group posts, some time I would like to seek some specific help from fellow members. My Question is: Is there any way I can disable Shift Bypass key for regular Network users but enable that privilege to Network Administrator Groups? Our Network...
3
11275
by: Scott Leonard | last post by:
Hello - I'm writing an application that will be used on "sometimes connected" devices (laptops, tablets). In C#, what is the best way to detect whether a network connection is present? I'd rather not rely on a network request timing out - the detection process must be very quick. Thanks in advance,
2
5143
by: Leonardo D'Ippolito | last post by:
Hi! I have two .NET win apps that need to communicate on a TCP/IP network. 'App A' must ask 'app B' if it's allowed to do some task, and 'app B' must authorize or prohibit it. How can I do this kind of communication in a secure way (protected from sniffing)? It would be a very simple protocol. Question, and two possible answers 'yes' or 'no'.
8
3032
by: BJ | last post by:
Problem: How can I code up a client side process to detect if the network is available? Synopsis: I am writing ASP.NET input forms for a Panasonic Tuff book. The users will be walking around the plant with a wireless connection. There are some pockets of non-connectivity. I've been tasked with disabling the submit button on the form if the network is unavailable. Possible solution: I can instantiate a timed process (VB.NET 2.0
5
24199
by: Goran Djuranovic | last post by:
Hi all, I have a file system watcher service that works fine on a local hard drive, but will not work across the network. I tried both: mapping the drive and "\\..." path both no luck. I don't receive any errors, it is just that FileSystemWatcher doesn't see any files dropped in the folder. What could be wrong? Thanks Goran
2
1707
by: salman | last post by:
we are developing new office, and now we are at stage to build office network, please kindly any help on the following issue to understand. - Components of a corporate network (Hardware Firewall, Cisco Pix501, Intrusion Detection System, etc.), - Design Issues in a corporate network, - Security Issues and Considerations in network design, - Role of Active Directory in network resource management, - Multi network integration Issues,...
2
2878
by: =?Utf-8?B?Um9ja3k=?= | last post by:
If the network cable is unplugged I need to change an image on my main form status bar, however this does not work ' The computer has been connected or disconnected from the network If e.IsNetworkAvailable = False Then My.Forms.MainForm.usbtest.Panels(2).Appearance.Image = My.Resources.server_error Else My.Forms.MainForm.usbtest.Panels(2).Appearance.Image = My.Resources.server_ok
4
2970
by: lillykalai | last post by:
Hi, i like to do a project in network intrusion detection...whether it is easy to implement in java or C++...give ur valuable information and suggestions regarding this topic,it will be very helpful...waiting for ur response...thank u....
0
9544
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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
10259
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...
1
10238
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7570
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
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.