Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C# Programming

Databinding takes high time


Hi,
In my usercontrol I bind the BindingSource I pass via property to all
the control inside the usercontrol.

For example

Control ctl=new TextBox();
ctl.DataBindings.Add("Text", binding, prop, false,
DataSourceUpdateMode.OnPropertyChanged);

via ANTS Profiler I see that it takes so much time and the UI seems
freeze (I have at least 10 controls to bind)

The behaviour slow down if I bind a combobox...

cmb.ValueMember = "Id";
cmb.DisplayMember = "Etichetta";
cmb.DataSource = binding;
cmb.DataBindings.Add("SelectedItem", binding, prop, true,
DataSourceUpdateMode.OnValidation, null);

at least 0,7 seconds for each control.

What is wrong? How can I speed up the binding task?

Thanks
Mauro

Mauro,

    There isn't much you can do, really.  Remember, data binding uses
reflection to perform its operations, and that is inherently slower than
other methods.

    The two things I can think of to speed up binding is to implement the
INotifyPropertyChanged interface, as it will not use reflection for change
notification on your type (assuming you are supporting it).

    Second, for your properties that you are bound to, just make sure that
you are not doing a lot of heavy work in them (but that should be obvious).

--
          - Nicholas Paldino [.NET/C# MVP]
          - m@spam.guard.caspershouse.com

"Mauro D." <mauro.destroSpam@tinspam.it> wrote in message

news:_St7i.24331$%k.107207@twister2.libero.it...

I'm not quite sure why it is *so* slow here, but if Nicholas is
correct (and reflection is the lag), you could try the following; this
improves the reflection -> component-model (i.e. what data-binding
uses) performance by a factor of roughly 180. Which is nice ;-p

http://www.codeproject.com/csharp/HyperPropertyDescriptor.asp

Marc

-----------------------------------------------Reply-----------------------------------------------

Nicholas Paldino [.NET/C# MVP] wrote:

> Mauro,

>    There isn't much you can do, really.  Remember, data binding uses
> reflection to perform its operations, and that is inherently slower than
> other methods.

>    The two things I can think of to speed up binding is to implement the
> INotifyPropertyChanged interface, as it will not use reflection for
> change notification on your type (assuming you are supporting it).

>    Second, for your properties that you are bound to, just make sure
> that you are not doing a lot of heavy work in them (but that should be
> obvious).

My class already implement the INotifyPropertyChanged interface...

My problem is not linked with a change in the property value but only in
the "startup time" of the binding.

Mauro

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc