473,624 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need help on the best why to query network status

I am currently working on an app the will be a shell replacement. Part of the
goal is to list the current network status; basically I need to know if the
network card is plugged in. I am currently using WMI to query all adapters to
see if they have a connected status. The status is updated every 30minutes. I
noticed this is leaking memory. I am looking for suggestions. I am running
this on an asynchronous thread call with callbacks to a delegate.
Nov 17 '05 #1
6 1859
30 minutes should be 30 seconds.

"Christophe r C" wrote:
I am currently working on an app the will be a shell replacement. Part of the
goal is to list the current network status; basically I need to know if the
network card is plugged in. I am currently using WMI to query all adapters to
see if they have a connected status. The status is updated every 30minutes. I
noticed this is leaking memory. I am looking for suggestions. I am running
this on an asynchronous thread call with callbacks to a delegate.

Nov 17 '05 #2
Why do you think this is leaking memory? Because you see the number in
the task manager go up? If this is the case, that is the normal behavior
for .NET, and it is not leaking memory.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:39******** *************** ***********@mic rosoft.com...
I am currently working on an app the will be a shell replacement. Part of
the
goal is to list the current network status; basically I need to know if
the
network card is plugged in. I am currently using WMI to query all adapters
to
see if they have a connected status. The status is updated every
30minutes. I
noticed this is leaking memory. I am looking for suggestions. I am running
this on an asynchronous thread call with callbacks to a delegate.

Nov 17 '05 #3
After an hour the program goes from using 18 megs to 59 megs. After 8 hours
it states the progrmaing is using 100 megs and the sytem is so slow it is
unusable.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Why do you think this is leaking memory? Because you see the number in
the task manager go up? If this is the case, that is the normal behavior
for .NET, and it is not leaking memory.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:39******** *************** ***********@mic rosoft.com...
I am currently working on an app the will be a shell replacement. Part of
the
goal is to list the current network status; basically I need to know if
the
network card is plugged in. I am currently using WMI to query all adapters
to
see if they have a connected status. The status is updated every
30minutes. I
noticed this is leaking memory. I am looking for suggestions. I am running
this on an asynchronous thread call with callbacks to a delegate.


Nov 17 '05 #4
But you still haven't answered the question. Are you looking at Task
Manager, or is there a performance counter that is indicating that you have
a memory leak.

If it is in fact a memory leak, there is a good chance that you are not
disposing of something properly. Are you sure that you are calling Dispose
on anything that implements IDisposable at the appropriate time? You might
think you are, but if there truly is a memory leak, this would be the most
obvious culprit.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
After an hour the program goes from using 18 megs to 59 megs. After 8
hours
it states the progrmaing is using 100 megs and the sytem is so slow it is
unusable.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Why do you think this is leaking memory? Because you see the number
in
the task manager go up? If this is the case, that is the normal behavior
for .NET, and it is not leaking memory.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:39******** *************** ***********@mic rosoft.com...
>I am currently working on an app the will be a shell replacement. Part
>of
>the
> goal is to list the current network status; basically I need to know if
> the
> network card is plugged in. I am currently using WMI to query all
> adapters
> to
> see if they have a connected status. The status is updated every
> 30minutes. I
> noticed this is leaking memory. I am looking for suggestions. I am
> running
> this on an asynchronous thread call with callbacks to a delegate.


Nov 17 '05 #5
I know I am the one creating the leak. What I am really looking for is a
better way to detect if the network cord is unplugged. Basically I need an
event to notify when there are changes to connectivity status. I am working
on my memory leak issue, but need to know if there is a better way then WMI.

"Nicholas Paldino [.NET/C# MVP]" wrote:
But you still haven't answered the question. Are you looking at Task
Manager, or is there a performance counter that is indicating that you have
a memory leak.

If it is in fact a memory leak, there is a good chance that you are not
disposing of something properly. Are you sure that you are calling Dispose
on anything that implements IDisposable at the appropriate time? You might
think you are, but if there truly is a memory leak, this would be the most
obvious culprit.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
After an hour the program goes from using 18 megs to 59 megs. After 8
hours
it states the progrmaing is using 100 megs and the sytem is so slow it is
unusable.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Why do you think this is leaking memory? Because you see the number
in
the task manager go up? If this is the case, that is the normal behavior
for .NET, and it is not leaking memory.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:39******** *************** ***********@mic rosoft.com...
>I am currently working on an app the will be a shell replacement. Part
>of
>the
> goal is to list the current network status; basically I need to know if
> the
> network card is plugged in. I am currently using WMI to query all
> adapters
> to
> see if they have a connected status. The status is updated every
> 30minutes. I
> noticed this is leaking memory. I am looking for suggestions. I am
> running
> this on an asynchronous thread call with callbacks to a delegate.


Nov 17 '05 #6

You better use an Eventwatcher to watch the 'MSNdis_MediaCo nnectStatus' ,
following gives you an idea how to proceed.

class Tester {
public static void Main() {
Tester we = new Tester();
ManagementScope scope = new ManagementScope ("root\\wmi" );
ManagementEvent Watcher w = null;
try {
WqlEventQuery q = new WqlEventQuery() ;
q.EventClassNam e = "__InstanceOper ationEvent";
q.WithinInterva l = new TimeSpan(0,0,3) ;
q.Condition = @"TargetInstanc e ISA 'MSNdis_MediaCo nnectStatus' ";
w = new ManagementEvent Watcher( q);
w.EventArrived += new EventArrivedEve ntHandler(we.Ne twEventArrived) ;
w.Start();
Console.ReadLin e(); // block main thread for test purposes
}
catch(Exception e) {
Console.WriteLi ne(e.Message);
}
finally {
w.Stop();
w.Dispose();
}
}
public void NetwEventArrive d(object sender, EventArrivedEve ntArgs e) {
//Get the Event object and show it
ManagementBaseO bject prop =
e.NewEvent.Prop erties["PreviousInstan ce"].Value as ManagementBaseO bject;
Console.WriteLi ne(Convert.ToBo olean(prop.Prop erties["NdisMediaConne ctStatus"].Value)?"Connec ted":"Disonnect ed");
}

}

Willy.

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:FD******** *************** ***********@mic rosoft.com...
I know I am the one creating the leak. What I am really looking for is a
better way to detect if the network cord is unplugged. Basically I need an
event to notify when there are changes to connectivity status. I am
working
on my memory leak issue, but need to know if there is a better way then
WMI.

"Nicholas Paldino [.NET/C# MVP]" wrote:
But you still haven't answered the question. Are you looking at Task
Manager, or is there a performance counter that is indicating that you
have
a memory leak.

If it is in fact a memory leak, there is a good chance that you are
not
disposing of something properly. Are you sure that you are calling
Dispose
on anything that implements IDisposable at the appropriate time? You
might
think you are, but if there truly is a memory leak, this would be the
most
obvious culprit.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
> After an hour the program goes from using 18 megs to 59 megs. After 8
> hours
> it states the progrmaing is using 100 megs and the sytem is so slow it
> is
> unusable.
>
> "Nicholas Paldino [.NET/C# MVP]" wrote:
>
>> Why do you think this is leaking memory? Because you see the
>> number
>> in
>> the task manager go up? If this is the case, that is the normal
>> behavior
>> for .NET, and it is not leaking memory.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard. caspershouse.co m
>>
>> "Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in
>> message
>> news:39******** *************** ***********@mic rosoft.com...
>> >I am currently working on an app the will be a shell replacement.
>> >Part
>> >of
>> >the
>> > goal is to list the current network status; basically I need to know
>> > if
>> > the
>> > network card is plugged in. I am currently using WMI to query all
>> > adapters
>> > to
>> > see if they have a connected status. The status is updated every
>> > 30minutes. I
>> > noticed this is leaking memory. I am looking for suggestions. I am
>> > running
>> > this on an asynchronous thread call with callbacks to a delegate.
>>
>>
>>


Nov 17 '05 #7

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

Similar topics

1
4495
by: B Golash | last post by:
Hi I`m trying to install a third-party control. During the install I receive this error...see the url below. I have no idea as to the meaning of the error. www.woodsolutions.com/download/ErrorLoadComp.jpg
3
2363
by: FRITSCH Vincent | last post by:
Hi, i need help on a query. I've this table : create table t ( customer number(5), time date, status varchar2(1)
5
566
by: Matt | last post by:
I'm designing an application that will be run on LAN-connected desktop PCs, and will also be run on laptops that may or may not be disconnected from the LAN. The application also needs to continue functioning if the network goes down. Looking for code to determine if a LAN connection is present first led me to Sysytem.Windows.Forms.SystemInformation.Network, but that appears to only tell you if a valid NIC is in the machine.......
1
1339
by: Keith Work | last post by:
I'm working on migrating about 2000 documents from one knowledge management system to another and am having a hard time with 1 report. Each record has (among other things) 1 of 3 units (categories) assigned to it (EBI, Network or Mainframe) and a few different statuses (which for arguments sake we can boil down to 3). I want the report to look like this (the numbers are just examples): Complete Incomplete Total EBI 10 ...
1
1334
by: Grammie | last post by:
I need a report that looks like this: 1. Number of Enrollees as of Today: (count of everyone in query){can count last names) 2. Total Active People (count of everyone with "A" as (=Status)) 3. Total Hold People (count of everyone with "HOLD" as Status
6
2858
by: seb | last post by:
Hi, I am using pygtk for the first times. I am wondering what would be the best "pattern" to interface pygtk with a thread. The thread is collecting informations (over the network for example) or is doing some long calculations.
12
2155
by: Kevin Blount | last post by:
I'm having a very odd issue, that arose this morning after working fine yesterday... here's a very simple script: 1: <?php 2: $test = $_GET; 3: echo "Hello" . $test . "<p>"; 4: ?>
5
2157
by: Justin | last post by:
Here's my XML: <?xml version="1.0" ?> <AppMode Type="Network"> <CurrentFolder Path="c:\tabs"> <Tabs> <FilePath>tabs\Justin.tab</FilePath> <FilePath>tabs\Julie.tab</FilePath> *****There could be 1 of these or 100....quantity can change***** </Tabs>
45
6846
by: angelicdevil | last post by:
i have 2 tables 1 is status_type with field name status and other is users with field username and status now i want that the first listbox lists all status from status type ( this i have achieved with php ) and based on selection of the value in listbox 1 the corresponding data in table users be loaded in listbox 2 . i have achieved this by using a button in php but i want tht it operate without submit button and no page refreshing ...
0
8681
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
8629
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
8341
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,...
0
8488
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
7170
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
6112
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
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
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
1488
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.