久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

TransactionScope 和多線程

TransactionScope and multi-threading(TransactionScope 和多線程)
本文介紹了TransactionScope 和多線程的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想知道在處理多線程時如何以正確的方式使用 TransactionScope 類?

I was wondering how you would use the TransactionScope class in the correct way when you are dealing with multithreading?

我們在主線程中創建了一個新的作用域,然后我們產生了幾個工作線程,我們希望這些線程參與到主作用域中,例如,如果作用域從未完成,則在每個工作線程上調用回滾.

We create a new scope in our main thread and then we spawn off a couple of worker threads and we want these to participate in the main scope, so that for example the rollback is called on each worker if the scope is never completed.

我在內部使用 ThreadStaticAttribute 閱讀了有關 TransactionScope 的內容,這使得上述操作變得不可能/非常困難 - 有人可以驗證任何一種方式嗎?如果我們以同步方式運行代碼,則回滾工作,即內部事務能夠參與主事務,但如果我們切換到線程執行則不行.

I read something about TransactionScope using the ThreadStaticAttribute internally which made the above impossible / very difficult - could someone verify either way? If we run our code in a synchronized fashion then the rollbacks work, i.e the inner transactions are able to participate in the main transaction, but not if we switch over to a threaded execution.

推薦答案

參見 MSDN:

您還應該使用 TransactionScope 和DependentTransaction 類需要使用的應用程序同一筆交易跨多個函數調用或多線程電話.

You should also use the TransactionScope and DependentTransaction class for applications that require the use of the same transaction across multiple function calls or multiple thread calls.

所以也許看看 DependentTransaction - 特別是,有一個工作線程示例,這里.

So maybe look into DependentTransaction - in particular, there is a worker thread example, here.

這篇關于TransactionScope 和多線程的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

SQL Server 2005 Transaction Level and Stored Procedures(SQL Server 2005 事務級和存儲過程)
Yield return from a try/catch block(try/catch 塊的收益回報)
Should I call Parameters.Clear when reusing a SqlCommand with a transation?(重用帶有事務的 SqlCommand 時,我應該調用 Parameters.Clear 嗎?)
Does SqlTransaction need to have Dispose called?(SqlTransaction 是否需要調用 Dispose?)
Reason for System.Transactions.TransactionInDoubtException(System.Transactions.TransactionInDoubtException 的原因)
How do I use TransactionScope with MySql and Entity Framework? (getting Multiple simultaneous connections...are not currently supported error)(如何將 TransactionScope 與 MySql 和實體框架一起使用?(獲取多個同時連接...目前不
主站蜘蛛池模板: 国产视频1区 | 国产免费一区 | 欧美在线国产精品 | 波多野结衣中文字幕一区二区三区 | 亚洲图片视频一区 | 嫩草影院网址 | 成人国产精品色哟哟 | 日韩欧美国产不卡 | 九九视频在线观看视频6 | 国产精品一码二码三码在线 | 欧美精品久久久久 | 99视频免费播放 | 羞羞在线观看视频 | 请别相信他免费喜剧电影在线观看 | 精国产品一区二区三区四季综 | 羞羞视频网站免费看 | 国产精品一区二区在线免费观看 | 超碰av免费| 午夜影视在线观看 | 99精品免费 | 美女黄网| 免费的一级视频 | 久久99精品国产99久久6男男 | 97精品国产97久久久久久免费 | 一区二区视频在线 | 国产精品99久久久久久动医院 | 欧美日韩在线不卡 | 伊人91在线 | 久久婷婷香蕉热狠狠综合 | 中文字幕一区二区三 | 欧产日产国产精品v | 毛片网站在线观看 | 成人自拍视频 | 国产在线视频三区 | 国产在线a视频 | 操操操av | 在线视频中文字幕 | 成年人视频在线免费观看 | 亚洲国产aⅴ成人精品无吗 亚洲精品久久久一区二区三区 | 欧美一级网站 | 狠狠色狠狠色综合日日92 |