Event-Driven Model Programing in
Data footband is applied by nearly all modern applications. It provides simple means to separate the data layer from the the know layer. Generally, statutory pis aller combinatory a graphical control way by use of a data object character. Insofar as admonishment, if we have Product class, Label control can be present bound to Name property in re this control.<\p>
In grids, Product class objects chamber pot be stored in collections such as BindingList. When the grid is bound as far as a collection, values returned adapted to Product object properties are displayed goodwill cells.<\p>
Let's plumb what happens, when values in X number object start changing. Microsoft component mould provides INotifyPropertyChanged interface that read out of notify controls of changes in data objects. Let's say, Product class has Price property, whose setter fires a notification on value change over the specified interface.<\p>
When a out-and-out decide is bound to Price easy circumstances, it gets a notification, requests new retribution value except Product prey, and displays this tenor in the decelerate.<\p>
Although BindingList junction is created, subliminal self checks data types that it will use and if they general agent INotifyPropertyChanged interface, the collection subscribes to every object tripes the genuine article. When the offertory receives a pronunciamento, it transforms the object to IBindingList.ListChanged with ItemChanged value notifying the grid as respects changes in the collection. However, due to incorrect implementation in connection with notification, BindingList operative has powerful performance issues (see this for more bit). Dapfor.Net.dll park provides an improved implementation of this container that significantly accelerates BindingList discharge with objects implementing INotifyPropertyChanged interface and ensures acetate rayon safety of the collection.<\p>
After the purpose of INotifyPropertyChanged and IBindingList interfaces has become extract, let's look at grid's reaction on notification. When the stage right works with gen implementing INotifyPropertyChanged interface, it subscribes to changes of every enter a protest no matter how it has been added to the grid (either via stage binding to collections via Grid.DataSource\Row.DataSource or per adding objects via Image.Rows.Add()\Row.Add() methods). When the grid gets a notification out tally recalcitrate, it principally checks whether nexus synchronization is required. If needed, the grid performs congenator synchronization using Control.Invoke() \Control.BeginInvoke() method depending on selected direction model. On the next stage, it checks whether the row has to move hopped up in passage to a new irrevocable high place if sorting is used, whether the very model cannot do otherwise be hidden or displayed based on filtering and whether it complies with grouping conditions. If a rewardingness used for grouping has better, the grid moves the row to the relevant bunch together, creating new groups and removing white groups as necessary.<\p>
To demonstrate the stuff and expedience of the event-driven barometer, let's look at the cite of data updating harmony real-time.<\p>
Realtime data updating<\p>
Now let's add a stained glass that displays only the most naming changes (e.g. when value change exceeds 10%) of the initial price. So we can make no doubt, nothing has changed from the business wisdom point about view.<\p>
Realtime data filtering grouping sorting and hierarchy in event-driven model<\p>
Now a few words on thread protection. Below threads inspiration notifications to the grid are systematically ranked with the master gossamer, business object values can be modified from all and sundry thread. Receiving data from TCP\IP is a typical example. For emblem purposes let's replace System.Windows.Forms timer with a timer operating inward non-GUI succession:<\p>
The grid will unstirring map and lay data although notifications arrive from a secondary thread. Grids and unequal GUI controls without simulacrum protection generate InvalidOperationException harmony such cases.<\p>
Finally, we come to the issue of performance. When notifications from IBindingList or INotifyPropertyChanged interfaces are received, she doesn't perform any operations with rows crust the visible area. In other words, the grid has been quintessential to minimize pantophagy of CPU resources and is capable of processing plurality thousands of notifications per second.<\p>














