Nhibernate和多线程

Sta*_*ker -1 c# windows nhibernate winforms

我有一个多线程应用程序它有这样的东西:

线程1:

    while(true)
    {
         //read data 

         //change and update
           thread.sleep(500);
    }
Run Code Online (Sandbox Code Playgroud)

线程2:

    //UpdateDate from time to time based on an event from somewhere else....
Run Code Online (Sandbox Code Playgroud)

应用程序只在发布时崩溃,它指出nhibernate中的一个方法"aftercommit"或者崩溃了我认为它与线程和nhibernate有关,我可以通过禁用缓存或nhibernate中的某些东西来考虑解决这个问题.

有没有人遇到类似的事情?任何想法如何完全禁用缓存?

环境:

Windows 7的..net4 Nhibernate 2.1 Windows Forms nhibernate由codemith nhibernate模板生成的dataaccess.

Jos*_*llo 5

在nhibernate中唯一线程安全的工件是会话工厂.确保您没有在不同线程之间使用相同的会话.