English 中文(简体)
.net, UserControls, and application start time
原标题:

We have a medium sized application that depends on several usercontrols, namely:

A tablelayout panel, with 2x5 grid of usercontrols, with 3+ levels of inheritance. A big issue we re running into with our application has proven to be startup time (both coldwarm), one of the big big hangups we re getting is initializing this usercontrol grid.

From our timing reports, this form comes in at about 0.75 seconds for initialization, and cutting this down would be a big deal.

My question is: What the heck can I do to speed this up? Whenever I run timing checks on similar-complexity InitializeComponents (all windows, .net controls), the result is magnitudes less (<10 milleseconds) sometimes.

edit) I m wondering if things like marking my final classes sealed or something similar would help.

edit2) I ve looked deeper into the timing of initializecomponent, and for my current machine, The main container adds 10 components to it (at 10ms a piece). Each of those components adds 3 components (at 10ms a piece). 10x10 + 30x10 = 700ms. Unless I can increase the speed at which items get added to their containers, I think I m SOL.

最佳回答

Are you doing anything that relies on external factors in the controls initiation, such as accessing the network, or pulling from a database? These can increase the load time of your application.

Check for any loops as well and try and reduce these.

问题回答

It may or may not be related, but I had a similar problem using the TableLayoutPanel. The problem was the drawing time, as revealed by a profiler. The combination that was causing problems for us was transparency on the inner controls and dynamic resizing. I played with some of the CreateParams options, but unfortunately, I ended up having to create a custom layout engine to make it really sing.

In any case, I would definately download a free trial version of a profiler right now. The performance problem is often in an unexpected location. You can spend hours optimizing somewhere you think is the culprit, only to gain 0.0001ms in performance difference.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签