ContextUtil.IsInTransaction 属性

定义

获取一个值,该值指示当前上下文是否为事务性上下文。

public:
 static property bool IsInTransaction { bool get(); };
public static bool IsInTransaction { get; }
static member IsInTransaction : bool
Public Shared ReadOnly Property IsInTransaction As Boolean

属性值

如果当前上下文是事务性的,则为 true;否则为 false

例外

没有可用的 COM+ 上下文。

示例

下面的代码示例获取 属性的值 IsInTransaction

[Transaction(TransactionOption::Required)]
public ref class ContextUtil_IsInTransaction: public ServicedComponent
{
public:
   void Example()
   {
      // Display whether the current COM+ context is enlisted in a
      // transaction.
      Console::WriteLine( "Current context enlisted in transaction: {0}", 
         ContextUtil::IsInTransaction );
   }
};
[Transaction(TransactionOption.Required)]
public class ContextUtil_IsInTransaction : ServicedComponent
{
    public void Example()
    {
        // Display whether the current COM+ context is enlisted in a
        // transaction.
        Console.WriteLine("Current context enlisted in transaction: {0}",
            ContextUtil.IsInTransaction);
    }
}
<Transaction(TransactionOption.Required)>  _
Public Class ContextUtil_IsInTransaction
    Inherits ServicedComponent
    
    Public Sub Example() 
        ' Display whether the current COM+ context is enlisted in a
        ' transaction.
        MsgBox("Current context enlisted in transaction: " & ContextUtil.IsInTransaction)

    End Sub
End Class

适用于