Alex Rivera | Logout

Is a static object the same object in multiple running applications?

Asked 2012-04-04T17:12:37.013
8

If you have a windows service and a windows forms application that uses the same static object, is it the same object in both applications? In other words if I update the object in the service will it also be updated in the forms application as well if both are running at the same time?

Edit
Report

1 Answer

0

The simple answer to this is is that each process has its own static so no, it will not be shared between the service and desktop process.

The complicated part is that there may even be multiple instances of a static in a single process.

In Java there is one instance of the static object for each ClassLoader that loads the class. I checked for equivalent functionality in C#. I found this question on SO that suggests that there is indeed something similar to multiple classloaders in in C# (I guess actually in CLR) and though I did not find any specific reference to multiple instances of a static I am sure that would be the case.

answered 2012-04-04T17:41:42.787

Your Answer