Beispiel #1
0
        /// <summary>
        /// Used to execute performance test run for memory profiler so the form is not loaded,
        /// only html container is working.
        /// </summary>
        public static void Run(bool layout, bool paint)
        {
            try
            {
                LoadRunSamples();

                var htmlContainer = new HtmlContainer();
                htmlContainer.MaxSize = new SizeF(800, 0);

                GC.Collect();
                Thread.Sleep(3000);

                using (var img = new Bitmap(1, 1))
                    using (var g = Graphics.FromImage(img))
                    {
                        for (int i = 0; i < Iterations; i++)
                        {
                            foreach (var html in _perfTestSamples)
                            {
                                htmlContainer.SetResourceServerAsync(new WinFormsDemoResourceServer(html));

                                if (layout)
                                {
                                    htmlContainer.PerformLayout(g);
                                }

                                if (paint)
                                {
                                    htmlContainer.PerformPaint(g);
                                }
                            }
                        }
                    }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
            }
        }