无法弄清楚为什么跨域调用对于FrameworkElementAdapters
课堂来说如此缓慢。这是一个简单的代码:
class Program
{
[STAThread]
static void Main()
{
AppDomain domain = AppDomain.CreateDomain("AnotherDomain");
var instance = (AnotherDomainClass) domain.CreateInstanceAndUnwrap(
typeof (AnotherDomainClass).Assembly.FullName,
typeof (AnotherDomainClass).FullName);
var contract = instance.CreateContract();
}
}
class AnotherDomainClass : MarshalByRefObject
{
public INativeHandleContract CreateContract()
{
return FrameworkElementAdapters.ViewToContractAdapter(
new TextBlock());
}
}
最后一行的执行时间instance.CreateContract
接近1.7 秒!哪里有问题?