How expensive are cross-domain operations?
I was curios how expensive is a cross domain operation so I have made a test.
The test procedure is simple. Perform a number of cross-domain and non cross-domain operations (get the value of NextNumber() from same domain and from another domain) and measure the time elapsed. For each value I have runned the application 3 times, recorded the time (in milliseconds) and created the mean of this three.
For this I’ve created a Console Application containing two classes, the main class and “NumberClass” which has a method that returns the next long. The code for this two is below:
NumberClass:
//MarshalByRefObject is used because this object will cross domain boundary class NumberClass:MarshalByRefObject { public ulong number = 0; public ulong NextNumber() { return number++; } }
The Main method from the main class:
EventInfo.AddEventHandler – bug or not?
Reflection is the process by which a computer program can observe and modify its own structure and behavior. The programming paradigm driven by reflection is called reflective programming. [Wikipedia]
Working a few days ago on a plugin architecture on .NET Framework I’ve found something very interesting. The method System.Reflection.EventInfo.AddEventHandler does late-binding. You’ll probably say “so what?”. Let’s see the problem with an example:
Using Visual Studio 2005/2008, create two C# projects (a windows forms application project and a class library one). Rename the class from the class library project to “TestClass.cs”.
