In the .process you do the work, i.e. using(var repository = new
WhateverRepository()) { return repository.GetAll(); }In the WhenFinished, you take that IList and bind it or do whatever you need to with it. Same story with updates, except I tend to just return the count of things updated and display that to the user instead of the list of businessobjects. I don't share sessions among repositories unless they need to participate in the same transaction so I don't run into the problem of needing to worry about multiple threads accessing the same session using this method. After reading the other separate post made today I think this is pretty similar to the option he is suggesting with the asyncmethod attribute. On Oct 1, 4:35 pm, justin coon <[email protected]> wrote: > webpaul, > > Refreshing an activerecord business object with the code i grabbed from your > post results in this exception. > "There is already an open DataReader associated with this Command which must > be closed first" > All im doing is calling a method thats calls .Refresh() on my business object > in the .Process() => and then it returns an int (since it doesnt support > methods with void return type." > > using > { > executer > .Process(() => > {}) > > .WhenFinished(businessObject => > { > BuildInvoiceViewModels(); > > }) > .Run(); > } > } > } > { > }intGetData()this.EndUser.Refresh();return1;(ThreadedExecuter<int> executer = > newThreadedExecuter<int>(this))returnGetData(); > > Any thoughts? > > ________________________________ > From: justin coon <[email protected]> > To: [email protected] > Sent: Thursday, October 1, 2009 4:12:06 PM > Subject: [nhusers] Re: WPF BackgroundWorker and NHibernate > > webpaul, > > thanks so much for your input...however i dont see you using nHibernate in > your example..this is the kicker to the problem. Nhibernate sessions are > associated with a thread and thats whats causing the problems for me....do > you know about nHibernate and doing things on another thread? > Appreciate your help and input very much!! > > Justin > > ________________________________ > From: webpaul <[email protected]> > To: nhusers <[email protected]> > Sent: Thursday, October 1, 2009 3:58:27 PM > Subject: [nhusers] Re: WPF BackgroundWorker and NHibernate > > I use this on all my winform projects for putting requests on the > background thread (including nhibernate ones) and then getting the > results when it is done, without having to mess with invokerequired or > anything. > > http://www.codeproject.com/KB/threads/ThreadedExecuter.aspx > > On Oct 1, 10:02 am, José F. Romaniello <[email protected]> wrote: > > > > > I've been very busy this weeks, I will write about it, be patient please. > > > 2009/9/30 justin coon <[email protected]> > > > > I would LOVE LOVE LOVE to see someone demonstrate how to do > > > multithreading with nHibernate on a desktop app(in particular a WPF > > > app) > > > > Ive been at 2 employers, both which would like to figure out if this > > > is possible, and if so, how to implement it. Right now i would be > > > happy with being able to do things in a background worker like the OP, > > > but i ran in to the exact same issues. Any chance Jose of you posting > > > some code? I would be so en debted. > > > > Thanks > > > Justin- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
