Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2007

Tip: Looking for answers? Try searching our database.

Databinding takes high time

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mauro D. - 31 May 2007 07:24 GMT
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
Nicholas Paldino [.NET/C# MVP] - 31 May 2007 14:23 GMT
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).

Signature

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

> Hi,
> In my usercontrol I bind the BindingSource I pass via property to all the
[quoted text clipped - 23 lines]
> Thanks
> Mauro
Mauro D. - 31 May 2007 16:17 GMT
> Mauro,
>
[quoted text clipped - 9 lines]
> 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
Marc Gravell - 31 May 2007 14:30 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.