public void DoCallBack(CrossContextDelegate deleg)
{
/*DBG Console.WriteLine("public DoCallBack: targetCtx: "
+ Int32.Format(this.InternalContextID,"x")); DBG*/
if (deleg == null)
{
throw new ArgumentNullException("deleg");
}
if ((_ctxFlags & CTX_FROZEN) == 0)
{
throw new RemotingException(
Environment.GetResourceString(
"Remoting_Contexts_ContextNotFrozenForCallBack"));
}
Context currCtx = Thread.CurrentContext;
if (currCtx == this)
{
// We are already in the target context, just execute deleg
// NOTE: If in the future we decide to leave the context
// and reenter it for this case we will need to change
// Context::RequestCallBack method in VM also!
deleg();
}
else
{
// We pass 0 for target domain ID for x-context case.
currCtx.DoCallBackGeneric(this.InternalContextID, deleg);
GC.KeepAlive(this);
}
}