首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

雪地裸跪,求答案关于TransactionScope的有关问题

2012-03-18 
雪地裸跪,求答案关于TransactionScope的问题请问TransactionScope是不是只是对数据库操作的事务处理?例如

雪地裸跪,求答案关于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

热点排行