From: NHibernate J. <nh...@gm...> - 2010-01-27 15:28:26
|
[ http://nhjira.koah.net/browse/NH-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=19039#action_19039 ] li yongjing commented on NH-2088: --------------------------------- In background thread, it can not use UI thread Session context. If I databind data in UI thead and commit it in background thread, it will do nothing and no sql flush. End use want to improve the UI responding, but i have a large mount of data to submit to SqlServer, if i use the single UI thread, it will display "NO Respongindg" in my app mainwindow, But if i use a new background thread to do this, it will be a problem because the session is not thread safe. So in my opinion, use APM is a better choice to deal with this problem. > IO APM Implement in NHibernate > ------------------------------ > > Key: NH-2088 > URL: http://nhjira.koah.net/browse/NH-2088 > Project: NHibernate > Issue Type: New Feature > Components: Core > Affects Versions: 3.0.0.Alpha1 > Reporter: li yongjing > Priority: Major > > many people hope a IO APM(http://msdn.microsoft.com/en-us/magazine/cc163467.aspx) Implement in NHibernate. We use SQL Server 2005 and we are building a client software. Now we have to execute SQL in UI Thread because of Session is not thread safe. It will display "No Respongding" in our application when a great amount of data to Submit to DB. > We know .net framework support IO-APM from version 2.0. The class SQLCommand has a method called "BeginExecuteNonQuery" and "EndExecuteNonQuery", It implements standard APM pattern. So We can use it to send async request to SQL Server. It return immediatly. When Database finished, It will callback and send the data We need. IO APM do not need another thread, just use hardware IOCP. So it will save computer resource and cost less CPU time. Some .net FCL implement APM, such as Stream.BeginRead, Delegate.BeginInvoke, SQLCommand.BeginExecuteNonQuery. As you know, .NET 4.0 enhance parallel task to use multicore support. We think if NHibernate implement APM will take full advantage of hardware support. > We have a glance at NHibernate source, We find it use the interface "IDBCommand.ExecuteNonQuery". The APM support only occurs in SQLCommand. So can you add a callback method like "IAsyncResult BeginExecuteNonQuery(AsyncCallback callback, object stateObject)? Although it only support SQL Server, it can decrease UI responding time and less cost of CPU resource. > In our opinion, If this function occurs in the next version, everyone who use NHibernate will reap the benefits of APM async pattern. > So could you help us to let NHibernate support APM? If you have any idea, please contact with us freely. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://nhjira.koah.net/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |