I have inherited some majorly spaghetti code (combination C#/VB) that I'm trying to understand here.
This appears to be a really weird situation where there are two successive calls to fire events to a remote object, which is being done by calling the DynamicInvoke method of a delegate, of the form:
delegate1.DynamicInvoke(args1);
// some code here
delegate2.DynamicInvoke(args2);
delegate1 and delegate2 both refer to methods in the same remote "subscriber" object.
According to everything I can read in the documentation, DynamicInvoke looks like it should be synchronous. But I can see, before my eyes, when I put breakpoints into the remote process, that the methods referred to by delegate1 and delegate2 are running simultaneously, in different threads.
Is this another Microsoft "undocumented feature"? Should I have expected this? Any explanations as to why this should be? And if it's meant to run asynchronously, how can DynamicInvoke have a return value?
Thanks! Shaul