雪地裸跪,求答案关于TransactionScope的问题
请问TransactionScope是不是只是对数据库操作的事务处理?
例如如下代码:
petshop4.0中OrderProcessor
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, tsTimeout)) {
// Receive the orders from the queue
for (int j = 0; j < batchSize; j++) {
try {
//only receive more queued orders if there is enough time
if ((elapsedTime + queueTimeout + transactionTimeout) < tsTimeout.TotalSeconds) {
queueOrders.Add(order.ReceiveFromQueue(queueTimeout));
}
else {
j = batchSize; // exit loop
}
//update elapsed time
elapsedTime = new TimeSpan(DateTime.Now.Ticks).TotalSeconds -
datetimeStarting.TotalSeconds;
}
catch (TimeoutException) {
//exit loop because no more messages are waiting
j = batchSize;
}
}
//process the queued orders
for (int k = 0; k < queueOrders.Count; k++) {
order.Insert((OrderInfo)queueOrders[k]);
processedItems++;
totalOrdersProcessed++;
}
//batch complete or MSMQ receive timed out
ts.Complete();
}
这里的事务处理中对queueOrders.Add(order.ReceiveFromQueue(queueTimeout));这句话起作用吗?这句代码是对队列的操作并不
是对数据库的操作,但是在事务处理里面。
------解决方案--------------------只在数据库事务操作中用到过。。。。
------解决方案--------------------
只是数据库的事务
------解决方案--------------------TransactionScope