Creating a Class That Participates in an Automatic Transaction

[ Team LiB ] Recipe Creating a Class That Participates in an Automatic Transaction Problem You need to create a .NET class that participates in automatic transactions. Solution Use the appropriate custom attributes from the namespace. | Team LiB Recipe Creating a Class That Participates in an Automatic Transaction Problem You need to create a .NET class that participates in automatic transactions. Solution Use the appropriate custom attributes from the namespace. The sample contains a component that participates in automatic transactions. The component has a single method TranTest that instructs the transaction to succeed or fail based on an argument success. The sample also contains code that instantiates the component that participates in the automatic transaction. A checkbox on the form is used to specify the success parameter when the TranTest method is called. The C code is shown in Examples Example 6-1 and Example 6-2. Example 6-1. ServicedComponentCS Project File Namespaces variables and constants using using using . . . namespace Transaction public class SC0601 ServicedComponent AutoComplete public void TranTest bool success . . . Do some work. if success II don t need the next line since AutoComplete else II Vote to abort. II Raise an exception. throw new Error in Serviced Component 0601. Transaction aborted. Example 6-2. File II Namespaces variables and constants using System using using II . . . SC0601 sc new SC0601 try Transaction successful. Automatic Transactions catch Exception ex Automatic Transactions Discussion The .NET Common Language Runtime CLR supports both manual and automatic transaction models. The automatic distributed transaction model supported by the .NET CLR is the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
10    476    2    18-05-2024
110    93    5    18-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.