开发者

Multi-threading access to SubmitChanges() (LINQ to SQL)

开发者 https://www.devze.com 2022-12-18 02:39 出处:网络
I am using Visual Studio 2010 Beta 2. In Parallel.For loop I execute the same method with different parameter values. After execution processed data must be stored in the database.

I am using Visual Studio 2010 Beta 2.

In Parallel.For loop I execute the same method with different parameter values. After execution processed data must be stored in the database.

But I've got an exception hat says that I could not work with the same data context from different threads.

So the question will be how to work with data context and SubmitChanges() fro开发者_JS百科m multiple threads?


I would recommend creating a threadsafe structure for storing your results. Once your parallel for has completed you can read these out of the structure and push them into your linq dataset.

0

精彩评论

暂无评论...
验证码 换一张
取 消