Pregunta

I have written an application in C#. Several methods are static. We run several of the C# applications at the same time.

Fact: Two of my colleagues told me that if we run 2 or more of this C# application that has these static methods, the application will slow down because each application has to share the static methods between each instance of the application.

I think this is totally incorrect and wanted to get others opinion on this.

Will running 2 or more instances of the same C# application that has static methods slow down due to the statement that the applications must "share" the static methods ?

¿Fue útil?

Solución

Your coworkers are totally incorrect.

Joking aside, each application will load the assembly with the static methods. They're not really "sharing" anything except the same library reference. For example, windows applications surely share calls to many of the same static methods yet they are not (ostensibly) slowed down by this.

Otros consejos

Mailman is right. If you have multiple instances of a class within the same running instance of a program then static members/variables are shared between those class instances, although still won't cause you to slow down.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top