riteshrao / ncommon

A framework for implementing commonly used design patterns when using Domain Driven Design
www.codeinsanity.com
218 stars 61 forks source link

Using UnitOfwork and parallell tasks #18

Open marvealmar opened 14 years ago

marvealmar commented 14 years ago

Hi, I have the following problem: I have an application which does extensive work. Until now all this have been done synchronously. But then I identified task that may as well run in parallell. Therefore I wanted to use the .net 4.0 parallell/task library. But when setting up this, I first get a problem with the UnitOfWorkScope. Running tasks in their own thread seems to loose the current UnitOfWorkScope I run the complete task in. So I then try to create a new scope within the working thread for the individual tasks, but then I received error "The underlying provider failed on EnlistTransaction".

I guess if I were able to get hold of the UnitOfWorkScope across threads, it would go well.

any solution/workaround to this?

marvealmar commented 14 years ago

Found a workaround. In my configuration of the repository I was using the DefaultStateConfiguration, and using a ThreadLocalStore for state storage. I implemented a new Store (ThreadSafe) by using the Synchronizer class from IDesign. Using this, the current TransactionMAnager/UnitOfWorkScope will be loaded from the store.

saurabhsharma81 commented 12 years ago

Hi, Can I have the implementation of the Store(ThreadSafe), I am also facing the same issue. saurabh.sharma81@gmail.com

marvealmar commented 12 years ago

Hi, I am sorry. I had this source code implemented at my former employer. I did not bring the source code with me:)

Another thing is that, if I were you, consider to not use NCommon. It has a lots of great ideas and implementations, but is seems to be a dead project and poorly documented (or samples).