Ran Sagy
Ran Sagy

Reputation: 648

WinForms Performance Case: Dynamic Form creation + binding

I'm working to try and improve an existing winforms project we have here at work. I'm a bit stranded for ideas right now, SO i figured i'd spill some details here and see what people can suggest.

The form works like this:

We have a list (gotten from a DB) that defines which controls are to be created, using fully qualified namespaces. The controls (usercontrols, basically) get created by reflection in turn, and eventualy added to a panel on the form. Now, Each control can have more in it, in a tree-like hierarchy of controls in the end.

Each control gets its own initialization, and in the end, A DataSet is given to the form (and all controls) as a DataSource, with databinding being added and taking place on each of them.

Especially, In some cases we bind a specific ROW to a control, rather than the DataTable/Set. So expect BindingManager Position calls to determine exact row, etc.

With about ~30 User controls, We get a lovely performance of about 10 seconds to open a new form, where the DataSet barely contains any data. Binding takes about 3-4 seconds from that.

In a complex state of data, We're talking about 30-40 seconds of opening time, with binding taking roughly half the time.

Now, this is very simplified and i bet we have alot of our own code causing some slowdowns, and i've profiled it to know some spots.

But the main problem of performance seems to be the binding.

I'd love to hear some suggestions on how to drill down and find performance issues of this sort, especially a way to sort the mess that is hundreds of bindings going off.

Upvotes: 0

Views: 539

Answers (1)

Kelmen
Kelmen

Reputation: 1063

is the time to retrieve all the settings from the db taking a portion?

reflection -> reflection emit, performance, but coding is pita.

how about separate the building process into 2: 1st is merely to contruct all the items, data items will be unbound/empty

then next round is th data binding part.

doing this, assuming the data binding is slow, at least ppl can see the things pop on the screen. and you can give reason/excuse that data binding is always suck, or you can look into this part of problem separately.

Upvotes: 1

Related Questions