Windows Services and transactions

Source: Internet
Author: User

Changed the previous one last weekend.ProgramChange a single-threaded Windows service to a new thread triggered by timer each time. The thread contains a database read and update flag transaction. I thought this could solve the problem that the timer interval was not too small, but it caused more difficult problems.
After the analysis, the previous transaction can still read the database. -- This results in repeated data processing;
I used sqlconnection. begintransaction () to create a transaction. However, an error occurs from time to time and an unknown exception is thrown.
Every time you debug the service, you need to append the process.

I found the information and prepared to solve the problem as follows:
ACID properties-ensure that transactions are non-severable, consistent, isolated, and persistent.
Isolation has an attribute isolationlevel in the begintransaction () method that can be set. Try it;
Begintransaction () throws an invalidoperationexception, but it indicates that parallel transactions are not supported.
What I want to find: "check the status of databases and tables (such as lock ......)" The method has not been found. I don't know if this exception can be solved.
And the connection string is: connect reset = true;

The attribute of "isolation level" is serial;
An exception occurred while capturing invalidoperationexception;
Remove CONNECT reset;

The program is normal. The trigger time is set to 1 second.

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.