472,811 Members | 1,870 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,811 software developers and data experts.

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 1821
30 minutes should be 30 seconds.

"Christopher 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.com

"Christopher C" <Ch**********@discussions.microsoft.com> wrote in message
news:39**********************************@microsof t.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.com

"Christopher C" <Ch**********@discussions.microsoft.com> wrote in message
news:39**********************************@microsof t.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.com

"Christopher C" <Ch**********@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.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.com

"Christopher C" <Ch**********@discussions.microsoft.com> wrote in message
news:39**********************************@microsof t.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.com

"Christopher C" <Ch**********@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.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.com

"Christopher C" <Ch**********@discussions.microsoft.com> wrote in message
news:39**********************************@microsof t.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_MediaConnectStatus' ,
following gives you an idea how to proceed.

class Tester {
public static void Main() {
Tester we = new Tester();
ManagementScope scope = new ManagementScope("root\\wmi");
ManagementEventWatcher w = null;
try {
WqlEventQuery q = new WqlEventQuery();
q.EventClassName = "__InstanceOperationEvent";
q.WithinInterval = new TimeSpan(0,0,3);
q.Condition = @"TargetInstance ISA 'MSNdis_MediaConnectStatus' ";
w = new ManagementEventWatcher( q);
w.EventArrived += new EventArrivedEventHandler(we.NetwEventArrived);
w.Start();
Console.ReadLine(); // block main thread for test purposes
}
catch(Exception e) {
Console.WriteLine(e.Message);
}
finally {
w.Stop();
w.Dispose();
}
}
public void NetwEventArrived(object sender, EventArrivedEventArgs e) {
//Get the Event object and show it
ManagementBaseObject prop =
e.NewEvent.Properties["PreviousInstance"].Value as ManagementBaseObject;
Console.WriteLine(Convert.ToBoolean(prop.Propertie s["NdisMediaConnectStatus"].Value)?"Connected":"Disonnected");
}

}

Willy.

"Christopher C" <Ch**********@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.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.com

"Christopher C" <Ch**********@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.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.com
>>
>> "Christopher C" <Ch**********@discussions.microsoft.com> wrote in
>> message
>> news:39**********************************@microsof t.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
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. ...
3
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
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...
1
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)...
1
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...
6
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...
12
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
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...
45
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
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...

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.