BlockLeftTop, PRELOAD BlockLeftBottom, PRELOAD BlockLeftStretch, PRELOAD BlockTop, PRELOAD BlockBottom, PRELOAD BlockStretch, PRELOAD BlockRightTop, PRELOAD BlockRightBottom, PRELOAD BlockRightStretch, PRELOAD
DeltaEngine

AbiTrafficMonitor Tool

by Benjamin Nitschke 8. August 2006 03:50
A couple of days back I made a blog post about Top 10 tools and included my version of the AppTrafficMonitorLite Tool, which is nice, but does not run very stable (crashes after a while). I couldn't figure out why this happens because the debugger only tells me that some unmanaged gdi stuff crashes (at random memory locations, thats fun).

Instead of analysing and fixing that tool forever while most of the code was not done by me and it is not structurized in a easy way, I decided to write a completly new tool to do the job. It is still based on the great SharpPcap library, which brings WinPcap to .NET. It will not support as many features and I will only implement stuff as I need it ^^

The most important features for me are the autoupdating traffic tray icon and the current and total traffic. More features will come in the detail window later, we are still at version 0.1. The detail window will show all current packages that go through your computer, all the application details and additional information and statistics about all network adapters.

Here is the download link:

Click here to download AbiTrafficMonitor.exe v0.1 (160 KB)


Update 2006-08-08: Fixed the increasing GDI handles bug (still caused crashes after several hours), now it runs REALLY stable :)

Here is a little info about this issue. This was the old code:

    // Set the new icon
    notifyIcon1.Icon = Icon.FromHandle(updatedIconBmp.GetHicon());

Looks ok, but with the help of ProcessExplorer I found out that this lines creates 3 new GDI handles and never releases it. I thought maybe something is wrong with GetHicon generating the bitmap, but that didn't cause it. So it must have something to do with the Icon.FromHandle method. I even tried out implementing the icon with Interop calls, but always as I set the new icon to the notify icon I got 3 new GDI handles, ARG! Finally I thought that the problem may not be in the Icon class, but in the NotifyIcon class and how the new Icon is applied. And thats exactly where the problem is. The Icon set property does not just assign the Icon, it does create a copy and manages the icon itself. So the only thing you have to do after assigning a Icon is to destroy it again (since NotifyIcon keeps its own copy):


    // Create new icon
    Icon newIcon = Icon.FromHandle(updatedIconBmp.GetHicon());

    // Set the new icon
    notifyIcon1.Icon = newIcon;

    // Destroy the icon, since the NotifyIcon keeps its own copy of the icon.
    // Note: This was the GDI memory leak before, is fixed now!

    DestroyIcon(newIcon.Handle);

[...]

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    extern static bool DestroyIcon(IntPtr handle);

Comments


4/28/2010 11:35:37 AM #

I\'m happy I found this blog, I couldnt discover any info on this subject matter prior to. I also run a site and if you want to ever serious in a little bit of guest writing for me if possible feel free to let me know, i\'m always look for people to check out my site. Please stop by and leave a comment sometime!

Rapidshare | Reply


Add comment




biuquote
  • Comment
  • Preview
Loading



Disclaimer: The opinions expressed in this blog are own personal opinions and do not represent the companies view.
© 2000-2011 exDream GmbH & MobileBits GmbH. All rights reserved. Legal/Impressum

Poll

Which platform should Soulcraft be released on next?











Show Results Poll Archive

Recent Games

Soulcraft

Fireburst

Jobs @ exDream

Calendar

<<  May 2012  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910