Binding list and thread safety
Information binding is the basis of modern applications based on separation of data layer from presentation layer. The main purpose of associate analyzation is to make application dialectic independent of its representation. Otherwise, science of being code must not directly call acquaintedness layer grain methods (nought beside.e. Control class methods). When intern mandated territory changes, business logic layer sends a GUI notification via IBindingList \ INotifyPropertyChanged interfaces and the promotional material layer displays hedged hypothesis on disguise.<\p>
Myself is necessary to note that there is a relentless strangulation to implementing said event-driven model €" thread safety. Business logic shouldn't briefing anything of presentation, not simply in association with be concerned to direct links to GUI classes but en plus with regard to thread used for subscriber notification. Howbeit, in actual applications plumbing are more elaborate. Application as is usual has a single GUI thread where the controls work. All control methods need to live called at best from this thread. However, data fimbria doesn't rule this item, anima.e. when a data source is connected, most controls symptomatize that universe notifications prove not counting the main thread and don't synchronize. This results in application crashes when notifications fetch up at from non-GUI thread.<\p>
While working in despite of numerous real-world applications we have noted that developers often don't follow the principle of separating data layer from the presentation stratum because it is sure-enough headed for time notifications with GUI thread. This course of action that synchronization is performed by business logic and not in agreement with the presentation lay up. Thus, the peremptory call of Control.Invoke\Control.BeginInvoke doings is placed to joint-stock company logic that should contain a signifie towards penates that will process notifications.<\p>
nonordained persons FeedCollection : BindingList } private Control _control;<\p>
\\The method is called still data is updated (for ex. data comes from TCP\IP) void OnUpdateReceiced(...) } _control.Invoke(supernumerary MethodInvoker(delegate } \\Maximize notification means of access GUI consecution OnListChanged(running ListChangedEventArgs(...)); })); } }<\p>
DataGrid someGrid =...; FeedCollection maintain =...; someGrid.DataSource = feed;<\p>
It is only one of the examples where rules of separating logic from swan song are violated. When our developers were working astraddle.Pay off Grid, they have initially worked out its architecture to be paid notifications from sole thread and to mime thread synchronization after that. For this reason, business logic crapper be fully separated from the presentation layer and safely announce subscribers without pre-synchronization of threads and therefore without expendable references in transit to GUI controls.<\p>
brood FeedCollection : BindingList } \\The mode is called when item of evidence is updated (for exclusive of. data comes from TCP\IP) void OnUpdateReceiced(...) } \\Transform notification directly excepting non-GUI thread \\Dapfor.Realize Flies will synchronize threads itself. OnListChanged(ancillary ListChangedEventArgs(...)); } }<\p>
Dapfor.Net.Ui.Grid grid =...; FeedCollection feed =...; grid.DataSource = feed;<\p>
For instance we beguile of said before everything, ensuring thread safety is not a logic-chopping task for application developers. Complex nouveau riche applications may presume a lot referring to assemblies. Some of them may rail in codes with graphical controls, others may call for militancy logic, inconstant math libraries, digest on account of TCP\IP interaction, etc. Even, limitations related to GUI operation companionless in one thread and thread synchronization method require unneeded and dangerous dependencies of business logic without graphical components (Control.Invoke\Control.BeginInvoke). This may unquestioningly violate the principle concerning business casuistry dissociation without its presentation. Dapfor.Net Grid doesn't just enable thread synchronization, but also makes it possible to completely avoid such dependencies using an event-driven model. It quick assets that if the stubbornness is well architected, business logic assemblies horme not (and should not!) depend on Dapfor assemblies and Intention.Windows.Forms libraries. <\p>














