Don't do this. Sessions are not thread safe.

On Tue, Sep 7, 2010 at 3:53 AM, Calin <[email protected]> wrote:

> Hi,
>
>  I am basically trying to take a long reading operation and make good
> use of the servers multi core processor. The basic serial operation
> looks like this:
>
>
>            foreach (TEntity entity in entities)
>            {
>                TBos bos = factory.Create(entity);
>                list.Add(bos);
>            }
>
>  factory.Create will take the entity and create a bussiness object out
> of it, in the process it might call thinks like entity.Categories or
> entity.Products witch are lazy loaded collections.
>
>  Now if I take all this and wrap it in a Parallel.Foreach(...) it will
> randomly crush when accessing the lazy loaded collections with "null
> object references". I am pretty sure is related to session management
> but I can seem to find a example of how to manage the session in multi
> threat environment.
>
>  So the question is, can anyone point me to a reference implementation
> that uses Nhibernate and multi-threading to read data ?
>
> Thank you very much,
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
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.

Reply via email to