I am trying to execute some logic on multiple AppDomains in parallel. I am doing this because I am working with legacy code which is "un-changeable" and I want to improve performance by parallelizing some things. The problem is that if I run multiple instances within 1 AppDomain they all rely on some static data structures and interfere with eachother.
My implementation is simple. I want to run multiple instances of my "ExecutionHarness" class - each in their own AppDomain - so I created a class "ExecutionHarnessProxy : MarshalByRefObject" which I instantiate in each of my AppDomains (since ExecutionHarness doesn't inherit from MarshalByRefObject). Then I just pass the "ExecutionData[] data" parameter to the "ExecutionHarnessProxy.Execute()" method. This guy then calls "ExecutionHarness.Execute()" and all is good.
My problem now is that whenever I pass my array of data to the proxy class, it takes FOREVER. The ExecutionData class has the [Serializable] attribute, and functionally it all works, but I was wondering if there is any way to speed this up.
- Could it be faster if I did the serialize/deserialize myself, on both sides of the AppDomain boundary?
- Is all of this time spent doing serialization? or is it just the transfer of the serialized data between AppDomains?