I am trying to get my head around how to use nhibernate in a multi-
threaded non asp.net application. Here is what i was thinking of
doing. Do you see any issues with doing the following? The code is
getting the current session inside of new thread that was set up by
the threadpool. Is getCurrentSession the proper way to get the
session in a multi-threaded application?
//business layer
widgetDao.Save(widget)
.
.
.
//called by business layer
public T Save (T entity)
{
WaitCallback workItem = new WaitCallback(MakePersistent,entity);
ThreadPool.QueueUserWorkItem(workItem);
}
//called by thread
protected Object MakePersistent(Object entity){
session = NHibernateHelper.GetCurrentSession();
session.SaveOrUpdate(entity);
//somehow return the newly saved entity back to business
layer since it may have a new id;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---