此示例说明了如何使用 System.EnterpriseServices.ContextUtil 类的静态 SetComplete 和 SetAbort 方法。有关这些方法的详细信息,请参阅自动事务中的投票。
示例
'Try to do something crucial to the transaction in progress.
If Not DoSomeWork() Then
ContextUtil.SetAbort() 'Something goes wrong.
Else
ContextUtil.SetComplete() 'All goes well.
End If
//Try to do something crucial to the transaction in progress.
if( !DoSomeWork() )
{
ContextUtil.SetAbort(); //Something goes wrong.
}
else
{
ContextUtil.SetComplete(); //All goes well.
}
编译代码
此示例需要:
- 引用 System 和 System.EnterpriseServices 命名空间。
请参见
概念
.gif)
版权所有 (C) 2007 Microsoft Corporation。保留所有权利。