System.Transactions Transaction Timeout setting

Source: Internet
Author: User

The System.Transactions has 2 timeout properties (timeout and maxtimeout), which can be set through a configuration file.

1. Timeout

The default timeout value of System.Transactions is 1 minutes and can be set by App.config/web.config/machine.config ( For specific transactions in your application, you can also set by invoking the constructor of the specific object TransactionScope or CommittableTransaction. The following configuration sample code sets it to 30 seconds:

<configuration> <system.transactions>  <defaultsettings timeout= "00:00:30"/> </ System.transactions></configuration>
2. Maximum Transaction timeout

System.Transactions There is also a property: Maximum transaction timeout, which is primarily used by system administrators to limit transaction timeouts, with a default value of 10 minutes, and the setting cannot be overridden in code . If the timeout value set in the configuration file or code exceeds the value, the value will prevail. Maximum transaction timeout can only be configured in the Machine.config file , the following configuration sample code sets it to 30 minutes:

<configuration> <system.transactions>   <machinesettings maxtimeout= "00:30:00"/> </ System.transactions></configuration>

In summary, even if timeout is set to 0 in the application's configuration file or code, attempting to set the transaction timeout to infinity is also invalid, and the actual time-out for the entire transaction is limited to the maxtimeout value of machinesetting.

Note: This is written when the code is set to non-default:

using (var scope = new TransactionScope (transactionscopeoption.required, New TimeSpan (0, 3, 0)))

Transactionscopeoption.required is the default, mainly for the back time parameter

System.Transactions Transaction Timeout setting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.