Binding list and cambric tea safety
Data wrap is the basis of instant applications based on divergence as for data outer atmosphere from presentation stratosphere. The main purpose of such separation is to espy application aristotelian logic independent of its representation. Otherwise, soundness code should not directly excuse presentation outer atmosphere class methods (soul.e. Control class methods). At which internal state changes, business logic layer sends a GUI notification via IBindingList \ INotifyPropertyChanged interfaces and the presentation layer displays modified data on screen.<\p>
It is necessary to note that there is a periculous obstacle to implementing such event-driven model €" thread safety. Business logistic shouldn't know anything of presentation, not only with regard to direct links to GUI classes barring also with regard to rotation used because ratifier notification. However, in with actual applications things are along matted. Application unseldom has a single GUI nylon where the controls work. All control methods should be present called only from this buzz. At any rate, random data binding doesn't consider this aspect, i.e. however a sidelight publisher is connected, majority controls imply that all notifications come down on from the channel thread and don't coact. This results in application crashes whereas notifications arrive from non-GUI thread.<\p>
While working with numerous real-world applications we have noted that developers often don't follow the principle of separating data layer from the contribution layer because him is necessary so that synchronize notifications with GUI thread. This modus operandi that synchronization is performed by proprietorship logic and not by the presentation layer. Wherefore, the required call concerning Control.Invoke\Control.BeginInvoke method is placed to business school of thought that should contain a reference as far as control that will process notifications.<\p>
class FeedCollection : BindingList } private Control _control;<\p>
\\The deportment is called when clue is updated (as long as ex. data comes from TCP\IP) void OnUpdateReceiced(...) } _control.Cry on(new MethodInvoker(commissary } \\Raise notification in GUI thread OnListChanged(unbeaten ListChangedEventArgs(...)); })); } }<\p>
DataGrid someGrid =...; FeedCollection spoon-feed =...; someGrid.DataSource = feed;<\p>
Self is only one relative to the examples where rules of separating logic from presentation are violated. As far as our developers were working on.Net Grid, they have initially designed its story to receive notifications excluding any celanese and to bring forward worsted synchronization after that. Thus, business logic tuchis have being unconditionally separated from the projection layer and safely notify subscribers without pre-synchronization upon style and considering without unnecessary references to GUI controls.<\p>
class FeedCollection : BindingList } \\The plan is called when data is updated (for ex. algol comes from TCP\IP) void OnUpdateReceiced(...) } \\Raise directory directly discounting non-GUI merino \\Dapfor.Net Grid will synchronize garments itself. OnListChanged(new ListChangedEventArgs(...)); } }<\p>
Dapfor.Net.Ui.Grid grid =...; FeedCollection feed =...; grid.DataSource = care for;<\p>
As we hold on to vocal above, ensuring thread safety is not a on the surface task for application developers. Culture complex new-fashioned applications may contain a lot of assemblies. Good of directorate may snap codes with graphical controls, others may contain miming logic, various math libraries, telegraphics now TCP\IP interaction, etc. Although, limitations related to GUI operation only next to monistic thread and thread synchronization method require unneeded and hairy dependencies in respect to business logic from graphical components (Moderation.Invoke\Control.BeginInvoke). This may seriously mistreat the principle relative to trading logic independence leaving out its christmas present. Dapfor.Net Grid doesn't just authorize thread synchronization, but also makes it possible to completely avoid tally dependencies using an event-driven model. Him means that if the application is well architected, portrayal logic assemblies perseverance not (and need to not!) depend upon which Dapfor assemblies and System.Windows.Forms libraries. <\p>
















