Speed up WPF startup

Source: Internet
Author: User

This is a good article,

Improving WPF applications startup time
Http://blogs.msdn.com/ B /jgoldb/archive/2007/10/10/improving-wpf-applications-startup-time.aspx

 

Abstract:

1. Warm Start is different with cold start.

2. Analysis start code.

3. Load fewer module, remove unuseful code and reference.

4. Avoid unnecessary init

5. Consider Avoiding application configuration.

6. Remove Authenticode
Generatepublisherevidence enabled = "false "/

7. Use neturalresourcelanguageattribute

8. databinding, don't use "datacontext" in XAML.

 

Get start time by coded-UI test code:

 

void log(string str)        {            Trace.WriteLine(string.Format(@"{0} | {1}", DateTime.Now.ToString("hh:mm:ss fff"), str));        }         void Test()        {            foreach (Process p in Process.GetProcesses())            {                if (p.ProcessName.ToUpper().Equals("BACKITUP"))                {                    p.Kill();                }            }            DateTime dt1 = DateTime.Now;            log("prepare");            string path = @"TestDemo.exe";             Process.Start(path);            log("start");             DateTime dt2 = DateTime.Now;            while (true)            {                try                {                    AutomationElement desktop = AutomationElement.RootElement;                    var condition = new System.Windows.Automation.PropertyCondition(AutomationElement.NameProperty, "MainWindow");                    var des = desktop.FindFirst(TreeScope.Children, condition);                    if (des == null)                        continue;                    else                    {                        condition = new System.Windows.Automation.PropertyCondition(AutomationElement.AutomationIdProperty, "button1");                        des = des.FindFirst(TreeScope.Children, condition);                        if (des != null)                            break;                    }                }                catch (Exception ex)                {                    Debug.WriteLine(ex);                    break;                }                 Thread.Sleep(5);            }            DateTime dt3 = DateTime.Now;            log("End");            var ts = dt3 - dt1;             log("total time: " + (ts.TotalMilliseconds / 1000d).ToString() + "s");        }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.