Castle ActiveRecord:不同线程中的会话错误搜索和延迟加载属性的访问
我在 C# 中使用 Castle ActiveRecord 的多线程桌面应用程序遇到了问题:
为了在根据用户输入搜索对象时保持 GUI 处于活动状态,我使用 BackgroundWorker
作为搜索功能。对象的某些属性,尤其是一些 HasMany
-Relations,被标记为 Lazy
。
现在,当搜索完成并且用户选择结果对象时,应该显示该对象的一些属性。但由于搜索是由不同线程中的 BackgroundWorker
完成的,因此访问属性会失败,因为延迟访问的会话不再可用。
在额外的线程中进行搜索以保持 GUI 处于活动状态并正确访问所有属性(包括标记为惰性的属性)的最佳方法是什么?
感谢您的任何建议!
问候 SC911
I've got a problem with an multi-threaded desktop application using Castle ActiveRecord in C#:
To keep the GUI alive while searching for the objects based on userinput I'm using the BackgroundWorker
for the search-function. Some of the properties of the objects, especially some HasMany
-Relations, are marked as Lazy
.
Now, when the search is finished and the user selects an resulting object, some of the properties of this object should be displayed. But as the search was done by the BackgroundWorker
in a different thread, accessing the properties fails as the session for the lazy-access is no longer available.
What will be the best way to do the search in an extra thread to keep the GUI alive and to access all properties correctly including those marked as lazy?
Thanks for any advise!
Regards
sc911
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有几个选项:
A couple of options:
通过这里这篇不错的博客文章解决了这个问题:
http: //www.darkside.co.za/archive/2008/09/09/castle-activerecord-lazy-loading-session-scopes-again.aspx
Solved it with this nice blog post here:
http://www.darkside.co.za/archive/2008/09/09/castle-activerecord-lazy-loading-session-scopes-again.aspx