TransactionOptions transactionOption = new TransactionOptions(); //设置事务隔离级别 transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; // 设置事务超时时间为60秒 transactionOption.Timeout = new TimeSpan(0, 0, 60); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, transactionOption)) { try { //执行代码 // 没有错误,提交事务 scope.Complete(); } catch (Exception ex) { throw new Exception("发送信息异常,原因:" + ex.Message); } finally { //释放资源 scope.Dispose(); } }