Click here to Skip to main content
15,846,038 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have a quick question.

I am writing a WPF application in C#. I want to add a Notify Icon. To do this I need to reference System.Windows.Forms.NotifyIcon.

My question is what will the effect be of adding the "using System.Windows.Forms.NotifyIcon" statement.

Will this dramatically effect the performance of the program at run time?

Assemblies are opened and loaded only when used, so adding references to your project have no effect until you use the types within it (the compiler will remove unused references).

At runtime performance is determined by what and how your references are being used and how they are implemented. Usually you will get a delay in the initial loading of the assemblies but later calls on cold start of your application (running again) will be faster.

To reduce the initial load time you can look into NGEN 'ing your assemblies which will reduce the load time.
Share this answer
StianSandberg 16-Aug-12 7:07am    
5'ed Ngen! But it's not straight forward...
MSDN: In order to get the optimal performance from NGen, all assemblies in the application need to be strong-named and installed into the Global Assembly Cache (GAC) prior to compilation. If an assembly is strong-named and not installed into the GAC, the loader will need to verify the assembly's signature at load time
Mehdi Gholam 16-Aug-12 7:16am    
cofka 18-Aug-12 14:40pm    
Thanks for your answer,

The reason I am asking is because a colleague of mine does not want to use System.Windows.Forms.NotifyIcon in WPF because he is concerned that it will fill memory at run time with all the garbage from System.Windows.Forms.
Mehdi Gholam 18-Aug-12 14:45pm    
WPF is way heavier than winforms, so it will make little difference.
well, an application does need what it needs to peform a certain task. And it only makes sense to modularise common functions into separate dlls that you then reference in your app and use them. The more of these you have, obviously, the app will be slightly slower because it has to load all these plus the overall app size also increases if the dlls are not part of the GAC. But the beauty is that the CLR optimises the loading of assemblies by something known as JIT(Just In-Time) and Pre-JIT compilation which delays loading a compiled dll until its actually used i.e. when you call a method from that dll so there is not much you can do worrying about referencing libraries, atleast the ones that are in the GAC. Hope this helps you a bit :)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900