這個範例示範如何使用 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)
Copyright © 2007 by Microsoft Corporation. All rights reserved.