在FrameworkElementAdapters类的性能 [英] Performance of the FrameworkElementAdapters class

查看:207
本文介绍了在FrameworkElementAdapters类的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想不通为什么跨域调用的是 FrameworkElementAdapters 类如此之慢。下面是一个简单的code:

Can't figure why cross-domain calls is so slow for FrameworkElementAdapters class. Here is a simple code:

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秒!哪里出了问题?

The execution time of the last line instance.CreateContract is near 1.7 sec! Where is a problem?

推荐答案

您是否尝试过装饰你的主要方法与<一个href="http://msdn.microsoft.com/en-us/library/vstudio/system.loaderoptimizationattribute%28v=vs.90%29.aspx"相对=nofollow> LoaderOptimizationAttribute 的设置为 LoaderOptimization.MultiDomainHost

Have you tried decorating your Main method with the LoaderOptimizationAttribute set to LoaderOptimization.MultiDomainHost?

FrameworkElementAdapters 类是System.AddIn的一部分。看一看<一href="http://blogs.msdn.com/b/clraddins/archive/2008/02/22/add-in-performance-what-can-you-expect-as-you-cross-an-isolation-boundary-and-how-to-make-it-better-jesse-kaplan.aspx"相对=nofollow>加载项性能:你能指望你穿越隔离边界,以及如何使其更好地形成System.AddIn团队的博客。也有看 WPF外接程序概述<的性能比较优化一节/ A> MSDN文章。

The FrameworkElementAdapters class is part of System.AddIn. Have a look at Add-In Performance: What can you expect as you cross an isolation boundary and how to make it better form the blog of the System.AddIn team. Also have a look at the "Perfomance Optimization" section of the WPF Add-Ins Overview MSDN article.

这篇关于在FrameworkElementAdapters类的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆