コード例 #1
0
        public static void CommitTransaction()
        {
            lock (_lock) {
                if (Transaction != null)
                {
                    _timer.Dispose();
                    _timer = null;

                    if (ManagementUnit.CommitRequested)
                    {
                        try {
                            ManagementUnit.ServerManager.CommitChanges();
                        }
                        catch {
                            AbortTransaction();
                            throw;
                        }
                    }

                    Transaction = null;

                    ManagementUnit.Dispose();
                    ManagementUnit = null;
                }
            }
        }
コード例 #2
0
        public static void AbortTransaction()
        {
            lock (_lock) {
                if (_timer != null)
                {
                    _timer.Dispose();
                    _timer = null;
                }

                Transaction = null;

                if (ManagementUnit != null)
                {
                    ManagementUnit.Dispose();
                    ManagementUnit = null;
                }
            }
        }
コード例 #3
0
        public static Transaction BeginTransaction()
        {
            lock (_lock) {
                if (Transaction == null)
                {
                    var transaction = new Transaction();
                    transaction.ExpiresOn = transaction.CreatedOn.AddMilliseconds(TRANSACTION_IDLE_TIMEOUT);

                    _timer = new Timer(TimeoutCallback, null, TRANSACTION_IDLE_TIMEOUT, Timeout.Infinite);


                    ManagementUnit = new ManagementUnit(transaction);
                    Transaction    = transaction;
                }
            }

            return(Transaction);
        }