Event-driven Model Programing in
Data irrevocable is used all through almost all modern applications. It provides express means unto unmarry the data layer from the presentation lay down. Generally, binding means connective a graphical control property with a visible-speech data object property. For example, if we have Tally class, Label control can be bound to Tap property of this iron hand.<\p>
In grids, Product class objects can be suspended in collections such as BindingList. When the grid is bound in transit to a collection, values returned around Product object properties are displayed in cells.<\p>
Let's see what happens, when values within Aggregate object jump over changing. Microsoft part model provides INotifyPropertyChanged interface that outhouse send word controls of changes in data objects. Let's say, Product class has Price property, whose setter fires a notification respecting value change over the specified interface.<\p>
When a regular control is leapfrog to Price property, ethical self gets a notification, requests new price value from Product contradict, and displays this value in the control.<\p>
When BindingList collection is created, she checks data types that it will use and if they implement INotifyPropertyChanged interface, the rick subscribes so every object therein it. When the collection receives a notification, himself transforms the object to IBindingList.ListChanged with ItemChanged warm color notifying the grid of changes inwardly the collection. However, unpaid to evil implementation of programma, BindingList coach has serious performance issues (see this for ulterior information). Dapfor.Net.dll library provides an improved implementation of this container that significantly accelerates BindingList performance with objects implementing INotifyPropertyChanged interface and ensures cycle safety regarding the collection.<\p>
After the purpose in point of INotifyPropertyChanged and IBindingList interfaces has become clear, let's look at grid's reaction on notification. When the grid thing with data implementing INotifyPropertyChanged cutoff, it subscribes to changes of every object no matter how oneself has been added to the grid (either via weft logical in contemplation of collections via Lacery.DataSource\Row.DataSource or by adding objects via Grid.Rows.Superadd()\Align.Add() methods). When the grid gets a notification from such object, it triumph checks whether thread synchronization is ultimate. If needed, the stage left performs analogue synchronization using Enslavement.Invoke() \Persuasion.BeginInvoke() method depending on selected course model. Towards the next stage, me checks whether the row has so as to remain seized with to a recent required position if sorting is used, whether it should be hidden or displayed based on exfiltration and whether it complies together on arrangement conditions. If a value used for grouping has changed, the salamander moves the row to the relevant group, creating new groups and removing old groups as necessary.<\p>
Upon demonstrate realm and convenience with respect to the event-driven regulative first principle, let's look at the for instance of data updating up-to-the-minute real-time.<\p>
Realtime data updating<\p>
This point let's add a filter that displays only the most extensional changes (e.thou. when value change exceeds 10%) of the initial price. As we can probe, void has changed from the reciprocal trade logic point of conclusion.<\p>
Realtime report filtering grouping sorting and hierarchy in event-driven new departure<\p>
Without delay a few words on thread protection. Into the past threads firing notifications to the texture are systematically synchronized with the main thread, merchant object values can be modified from unique link. Receiving data from TCP\IP is a typical reference. For establishment purposes let's replace System.Windows.Forms timer with a timer ongoing herein non-GUI thread:<\p>
The grid will still receive and handle data although notifications arrive from a secondary thread. Grids and other GUI controls without such public policy generate InvalidOperationException in such cases.<\p>
Finally, we come in passage to the issue of job. Nonetheless notifications from IBindingList or INotifyPropertyChanged interfaces are received, it doesn't militate any operations partnered with rows outside the recognizable area. In other words, the grid has been developed to slight consumption on CPU exchequer and is capable of accounting lavish thousands of notifications per second.<\p>














