SetCurrent() public static method

Sets the current transaction context. Please note that in most cases, it is not necessary to set the context using this method - when using DefaultTransactionContextScope and DefaultSyncTransactionContextScope the ambient transaction context is automatically set/unset when the object is created/disposed.
public static SetCurrent ( ITransactionContext transactionContext ) : void
transactionContext ITransactionContext
return void
Example #1
0
 /// <summary>
 /// Disposes the transaction context and removes it from <see cref="AmbientTransactionContext.Current"/> again
 /// </summary>
 public void Dispose()
 {
     try
     {
         _transactionContext?.Dispose();
     }
     finally
     {
         AmbientTransactionContext.SetCurrent(null);
     }
 }
Example #2
0
 /// <summary>
 /// Creates a new transaction context and mounts it on <see cref="AmbientTransactionContext.Current"/>, making it available for Rebus
 /// to pick up
 /// </summary>
 public DefaultTransactionContextScope()
 {
     AmbientTransactionContext.SetCurrent(_transactionContext);
 }
Example #3
0
 /// <summary>
 /// Creates a new transaction context and mounts it on <see cref="AmbientTransactionContext.Current"/>, making it available for Rebus
 /// to pick up. The context can also be retrieved simply via <see cref="TransactionContext"/>
 /// </summary>
 public RebusTransactionScope()
 {
     AmbientTransactionContext.SetCurrent(_transactionContext);
 }
Example #4
0
 /// <summary>
 /// Creates a new transaction context and mounts it on <see cref="AmbientTransactionContext.Current"/>, making it available for Rebus
 /// to pick up. The context can also be retrieved simply via <see cref="TransactionContext"/>
 /// </summary>
 public RebusTransactionScope()
 {
     _previousTransactionContext = AmbientTransactionContext.Current;
     AmbientTransactionContext.SetCurrent(_transactionContext);
 }