<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dapfor.Net Grid Blog &#187; thread safety</title>
	<atom:link href="http://www.blog.dapfor.com/thread-safety/feed" rel="self" type="application/rss+xml" />
	<link>http://www.blog.dapfor.com</link>
	<description>.Net Grid and MFC Grid</description>
	<lastBuildDate>Fri, 09 Sep 2016 05:40:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Wpf GridControl v4.0.0 has been released</title>
		<link>http://www.blog.dapfor.com/wpf-gridcontrol-v4-0-0-has-been-released</link>
		<comments>http://www.blog.dapfor.com/wpf-gridcontrol-v4-0-0-has-been-released#comments</comments>
		<pubDate>Mon, 25 Apr 2016 15:49:54 +0000</pubDate>
		<dc:creator>dapadm</dc:creator>
				<category><![CDATA[Data binding]]></category>
		<category><![CDATA[new release]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[thread safety]]></category>
		<category><![CDATA[cell blinking]]></category>
		<category><![CDATA[datatemplate]]></category>
		<category><![CDATA[GridControl]]></category>
		<category><![CDATA[styles]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[Wpf]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://www.blog.dapfor.com/?p=261</guid>
		<description><![CDATA[During development, we discovered that although WPF technology has many advantages, it utilizes a lot of computer resources. Therefore, creating a high quality and high performance product requires significant developer experience and deep understanding of technology. Out developers have invested of lot of effort in GridControl and as the result it has all the advantages of its [...]]]></description>
			<content:encoded><![CDATA[<p>During development, we discovered that although WPF technology has many advantages, it utilizes a lot of computer resources. Therefore, creating a high quality and high performance product requires significant developer experience and deep understanding of technology. Out developers have invested of lot of effort in <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol">GridControl</a> and as the result it has all the advantages of its predecessor, <a href="http://www.dapfor.com/en/net-suite/net-grid">.Net Grid</a>, including high performance.<br />
&nbsp;</p>
<div><img class="aligncenter" src="http://doc.dapfor.com/wpf-suite/media/features_6.png" alt="Wpf GridControl" width="685" height="411" align="center" /></div>
<p>&nbsp;</p>
<div>We have preserved <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/features/thread-safety">thread safety</a> of dynamic data in non-graphical thread enabling implementation of a thread-safe <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part3">event-driven model</a>. GridControl is the only graphical component that is able receive notifications (price changes or any other information) from the business model and from any thread.However, we mainly focused on ease of use, intuitiveness and minimization of code volume in final application. As the result, the grid supports <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part1">any data types</a>, creating any kind of <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/features/binding-row">hierarchy</a>, <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part9">sorting</a>, <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part11">filtering</a> and <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part10">grouping</a>. All of these features require just a few code lines.</p>
<p>The Wpf GridControl is the only component providing real-time services of simultaneous data grouping, sorting and filtering. This problem is very complex for developers to solve. As example, imagine blotter displaying several dozens shares sorted by constantly changing percentage of price fluctuation. In addition to that, users can apply filters to display only shares with the highest price change. A lot of complex and inefficient code is required to implement this functionality in other grid. Our GridControl has integrated data sorting, filtering and grouping services that continuously display rows in correct order even when they change all the time.<br />
&nbsp;
</p></div>
<div><img class="aligncenter" src="http://doc.dapfor.com/wpf-suite/media/features.png" alt="Wpf GridControl features" width="675" height="275" align="center" /></div>
<div>
&nbsp;<br />
We have also moved the feature of short-term <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part12">cell blinking</a> from .Net Grid to the new product. Users can set highlighting color and duration for individual cells using the provided callbacks.</p>
<p>We haven&#8217;t forgotten about specific advantages of WPF technology and now our application can display any controls in grid cells with <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part5">DataTemplate and DataTemplateSelector</a>. You can also alter grid appearance easily using <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part6">preset or custom styles</a>.
</div>
<p>&nbsp;</p>
<div>
<img class="aligncenter" src="http://doc.dapfor.com/wpf-suite/media/features_5.png" alt="Wpf GridControl data templates" />
</div>
<p>&nbsp;</p>
<div>
We hope that you will be surprised by outstanding quality of our work and really appreciate it.</p>
<p>We believe that our products will deserve your attention and that with our help you will develop excellent high-performance user-friendly applications.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dapfor.com/wpf-gridcontrol-v4-0-0-has-been-released/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binding list and thread safety</title>
		<link>http://www.blog.dapfor.com/binding-list-and-thread-safety</link>
		<comments>http://www.blog.dapfor.com/binding-list-and-thread-safety#comments</comments>
		<pubDate>Mon, 13 Feb 2012 21:05:28 +0000</pubDate>
		<dc:creator>dapadm</dc:creator>
				<category><![CDATA[Data binding]]></category>
		<category><![CDATA[thread safety]]></category>
		<category><![CDATA[databinding]]></category>
		<category><![CDATA[INotifyPropertyChanged]]></category>
		<category><![CDATA[threading]]></category>
		<category><![CDATA[threadsafety]]></category>

		<guid isPermaLink="false">http://www.blog.dapfor.com/?p=64</guid>
		<description><![CDATA[Data binding is the basis of modern applications based on separation of data layer from presentation layer. The main purpose of such separation is to make application logic independent of its representation. Otherwise, logic code should not directly call presentation layer class methods (i.e. Control class methods). When internal state changes, business logic layer sends [...]]]></description>
			<content:encoded><![CDATA[<p>Data binding is the basis of modern applications based on separation of data layer from presentation layer. The main purpose of such separation is to make application logic independent of its representation. Otherwise, logic code should not directly call presentation layer class methods (i.e. Control class methods). When internal state changes, business logic layer sends a GUI notification via <strong>IBindingList</strong> / <strong>INotifyPropertyChanged</strong> interfaces and the presentation layer displays modified data on screen. </p>
<p>It is necessary to note that there is a serious obstacle to implementing such event-driven model – thread safety. Business logic shouldn’t know anything of presentation, not only with regard to direct links to GUI classes but also with regard to thread used for subscriber notification. However, in actual applications things are more complicated. Application usually has a single GUI thread where the controls work. All control methods should be called only from this thread. However, data binding doesn’t consider this aspect, i.e. when a data source is connected, most controls imply that all notifications come from the main thread and don’t synchronize. This results in application crashes when notifications arrive from non-GUI thread. </p>
<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 presentation layer because it is necessary to synchronize notifications with GUI thread. This means that synchronization is performed by business logic and not by the presentation layer. Thus, the required call of <strong>Control.Invoke</strong>/<strong>Control.BeginInvoke</strong> method is placed to business logic that should contain a reference to control that will process notifications. </p>
<pre>
class FeedCollection : BindingList&lt;Feed&gt;
{
    <strong>private Control _control;</strong>

    //The method is called when data is updated (for ex. data comes from TCP/IP)
    void OnUpdateReceiced(...)
    {
        _control.Invoke(new MethodInvoker(delegate
        {
            //Raise notification in GUI thread
            OnListChanged(new ListChangedEventArgs(...));
        }));
    }
}

DataGrid someGrid = ...;
FeedCollection feed = ...;
someGrid.DataSource = feed;
</pre>
<p><br/><br />
It is only one of the examples where rules of separating logic from presentation are violated. When our developers were working on .Net Grid, they have initially designed its architecture to receive notifications from any thread and to perform thread synchronization after that. Thus, business logic can be fully separated from the presentation layer and safely notify subscribers without pre-synchronization of threads and therefore without unnecessary references to GUI controls. </p>
<pre>
class FeedCollection : BindingList&lt;Feed&gt;
{
    //The method is called when data is updated (for ex. data comes from TCP/IP)
    void OnUpdateReceiced(...)
    {
        //Raise notification directly from non-GUI thread
        //Dapfor .Net Grid will synchronize threads itself.
        OnListChanged(new ListChangedEventArgs(...));
    }
}

Dapfor.Net.Ui.Grid grid = ...;
FeedCollection feed = ...;
grid.DataSource = feed;
</pre>
<p><br/></p>
<p>As we have said above, ensuring thread safety is not a trivial task for application developers. Complex modern applications may contain a  lot of assemblies. Some of them may contain codes with graphical controls, others may contain business logic, various math libraries, code  for TCP/IP interaction, etc. However, limitations related to GUI operation only in one thread and thread synchronization method require unneeded and dangerous dependencies of business logic from graphical components (Control.Invoke/Control.BeginInvoke).  This may seriously violate the principle of business logic independence from 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 means that if the application is well architected,  business logic assemblies will not (and should not!) depend on Dapfor assemblies and System.Windows.Forms libraries.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dapfor.com/binding-list-and-thread-safety/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
