public void Dispose()
 {
     if (isDisposed)
     {
         return;
     }
     GameObject.Destroy(menu);
     OnDispose?.Invoke();
 }
Example #2
0
        /// <summary>
        /// Attach to a running process or start a new if not found.
        /// </summary>
        public static Application AttachOrLaunch(ProcessStartInfo processStartInfo, OnDispose onDispose = OnDispose.LeaveOpen)
        {
            if (TryAttach(processStartInfo, onDispose, out var app))
            {
                return(app);
            }

            return(Launch(processStartInfo, onDispose));
        }
Example #3
0
 public SchedulableGeneratorThunk(IEnumerator<object> task)
 {
     _Task = task;
     _QueueStep = QueueStep;
     _QueueStepOnComplete = QueueStepOnComplete;
     _QueueStepOnDispose = QueueStepOnDispose;
     _OnErrorChecked = OnErrorChecked;
     _Step = Step;
 }
 public SchedulableGeneratorThunk(IEnumerator <object> task)
 {
     _Task                = task;
     _QueueStep           = QueueStep;
     _QueueStepOnComplete = QueueStepOnComplete;
     _QueueStepOnDispose  = QueueStepOnDispose;
     _OnErrorChecked      = OnErrorChecked;
     _Step                = Step;
 }
Example #5
0
        /// <summary>
        /// Start the application.
        /// </summary>
        /// <param name="exeFileName">The full file name of the exeFileName.</param>
        /// <param name="args">The start arguments.</param>
        /// <param name="onDispose">Specify if the app should be left running when this instance is disposed.</param>
        public static Application Launch(string exeFileName, string args, OnDispose onDispose = OnDispose.KillProcess)
        {
            exeFileName = FindExeOrDefault(exeFileName, exeFileName);
            var processStartInfo = new ProcessStartInfo(exeFileName)
            {
                Arguments = args
            };

            return(Launch(processStartInfo, onDispose));
        }
Example #6
0
            public void Dispose()
            {
                if (this.OnDispose == OnDispose.KillProcess)
                {
                    this.OnDispose = OnDispose.LeaveOpen;
#pragma warning disable IDISP007 // Don't dispose injected.
                    this.Process.Dispose();
#pragma warning restore IDISP007 // Don't dispose injected.
                }
            }
Example #7
0
        public void Execute(OnDispose pipelineEvent)
        {
            var queue = pipelineEvent.Pipeline.State.Get <MessageQueue>("queue");

            queue?.Dispose();

            var journalQueue = pipelineEvent.Pipeline.State.Get <MessageQueue>("journalQueue");

            journalQueue?.Dispose();
        }
Example #8
0
        /// <summary>
        /// Disposes of the game mode.
        /// </summary>
        public virtual void Dispose()
        {
            if (OnDispose != null)
            {
                OnDispose.Invoke();
            }

            OnDispose  = null;
            CurrentMap = null;
        }
Example #9
0
 public void Dispose()
 {
     if (!helpIAmBeingHacked)
     {
         SqlConnection.Close();
         SqlConnection.Dispose();
         SqlConnection = null;
         OnDispose?.Invoke();
     }
 }
Example #10
0
 public override void Dispose()
 {
     while (CacheStack.Count > 0)
     {
         TComponent item = CacheStack.Pop();
         OnDispose?.Invoke(item);
         Object.Destroy(item.gameObject);
     }
     CacheStack.Clear();
 }
 /// <summary>
 /// 释放对象.
 /// </summary>
 public void Dispose()
 {
     if (_disposed)
     {
         return;
     }
     _transaction?.Dispose();
     _dbContext.Dispose();
     OnDispose?.Invoke();
     _disposed = true;
 }
Example #12
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposedValue)
     {
         OnDispose?.Invoke(this, this.DocumentsToInsert);
         if (disposing)
         {
         }
         _disposedValue = true;
     }
 }
Example #13
0
        /// <summary>
        ///     Releases all resources used by the object.
        /// </summary>
        public virtual void Dispose()
        {
            // Raise the event OnDispose
            OnDispose?.Invoke(this, new EventArgs());

            //// Close the process handle
            //Handle.Close();

            // Avoid the finalizer
            GC.SuppressFinalize(this);
        }
Example #14
0
        public void Dispose()
        {
            Stop();
            stream?.Dispose();
            stream = null;

            mes?.Dispose();
            mes = null;

            OnDispose?.Invoke(this, null);
        }
Example #15
0
        public TransactionManager(ConnectionStringSettings connectionStringSettings, OnDispose onDispose)
        {
            DbConnection = DbFactory.CreateConnection(connectionStringSettings);
            DbConnection.Open();

            _transactionStack = new Stack <IDbTransaction>();

            BeginTransaction();

            _onDispose = onDispose;
        }
Example #16
0
        protected virtual void Dispose(bool isDisposing)
        {
            if (!IsDisposed)
            {
                Marshal.FreeHGlobal(new IntPtr(_memoryBlock));
                AllocatedBytes = 0;
                IsDisposed     = true;

                OnDispose?.Invoke();
            }
        }
        public void Execute(OnDispose pipelineEvent)
        {
            var tx = pipelineEvent.Pipeline.State.Get <MessageQueueTransaction>();

            if (tx == null)
            {
                return;
            }

            tx.Dispose();
            pipelineEvent.Pipeline.State.Replace <MessageQueueTransaction>(null);
        }
Example #18
0
        protected override void Dispose(bool isDisposing)
        {
            OnDispose?.Invoke(IsDisposable, null);

            if (IsDisposable && texture != null)
            {
                texture.Dispose();
                texture = null;
            }

            base.Dispose(isDisposing);
        }
Example #19
0
 public void Dispose()
 {
     if (_encryptionBuffers != null) // Encryption enabled
     {
         foreach (var buffer in _encryptionBuffers)
         {
             NativeMemory.Free4KbAlignedMemory(buffer.Pointer, buffer.Size, buffer.AllocatingThread);
         }
         BeforeCommitFinalization?.Invoke(this);
     }
     OnDispose?.Invoke(this);
 }
Example #20
0
            public void Dispose()
            {
                lock (_semaphore)
                {
                    OnDispose();
                    foreach (var @delegate in OnDispose.GetInvocationList())
                    {
                        OnDispose -= @delegate as Action;
                    }

                    _semaphore.Dispose();
                    _isDisposed = true;
                }
            }
Example #21
0
        /// <summary>
        /// Free resources
        /// </summary>
        public void Dispose()
        {
            if (_Process != null)
            {
                foreach (var p in _Process)
                {
                    try { p.Dispose(); } catch { }
                }

                _Process = null;
            }

            OnDispose?.Invoke(null, null);
        }
        /// <summary>
        /// Attach to a running process if found.
        /// </summary>
        public static bool TryAttach(ProcessStartInfo processStartInfo, OnDispose onDispose, [NotNullWhen(true)] out Application?result)
        {
            if (processStartInfo is null)
            {
                throw new ArgumentNullException(nameof(processStartInfo));
            }

            var exeFileName = Path.GetFullPath(processStartInfo.FileName);

            lock (Launched)
            {
                var launched = Launched.FirstOrDefault(x => Path.GetFullPath(x.StartInfo.FileName) == exeFileName &&
                                                       x.StartInfo.Arguments == processStartInfo.Arguments);
                if (launched is { })
Example #23
0
 /// <summary>
 /// Does the same as stop. Does not need to be called for cleanup will be called after the execution has finished.
 /// </summary>
 public void Dispose()
 {
     if (_disposed)
     {
         return;
     }
     OnDispose?.Invoke(this, EventArgs.Empty);
     _isRunning = false;
     _disposed  = true;
     if (gameObject != null)
     {
         Destroy(gameObject);
     }
 }
Example #24
0
        /// <summary>
        /// Attach to a running process
        /// </summary>
        public static Application Attach(Process process, OnDispose dispose = OnDispose.LeaveOpen)
        {
            //// Logger.Default.Debug($"[Attaching to process:{process.Id}] [Process name:{process.ProcessName}] [Process full path:{process.MainModule.FileName}]");
            var app          = new Application(new ProcessReference(process, dispose));
            var windowHandle = app.MainWindow.NativeWindowHandle;

            if (windowHandle != new IntPtr(0))
            {
                User32.SetForegroundWindow(windowHandle);
                Wait.UntilResponsive(app.MainWindow);
            }

            return(app);
        }
Example #25
0
        public void Dispose()
        {
            if (_encryptionBuffers != null) // Encryption enabled
            {
                foreach (var buffer in _encryptionBuffers)
                {
                    PlatformSpecific.NativeMemory.Free4KbAlignedMemory(buffer.Pointer, buffer.Size, buffer.AllocatingThread);
                }

                var cryptoPagerTransactionState = ((IPagerLevelTransactionState)this).CryptoPagerTransactionState;

                if (cryptoPagerTransactionState != null && cryptoPagerTransactionState.TryGetValue(_dataPager, out var state))
                {
                    // we need to iterate from the end in order to filter out pages that was overwritten by later transaction
                    var sortedState = state.OrderByDescending(x => x.Key);

                    var overflowDetector = new RecoveryOverflowDetector();

                    foreach (var buffer in sortedState)
                    {
                        if (buffer.Value.SkipOnTxCommit)
                        {
                            continue;
                        }

                        if (buffer.Value.Modified == false)
                        {
                            continue; // No modification
                        }
                        var pageHeader    = (PageHeader *)buffer.Value.Pointer;
                        var numberOfPages = VirtualPagerLegacyExtensions.GetNumberOfPages(pageHeader);

                        long modifiedPage = buffer.Key;

                        if (overflowDetector.IsOverlappingAnotherPage(modifiedPage, numberOfPages))
                        {
                            // if page is overlapping an already seen page it means this one was freed, we must skip it on tx commit
                            state[modifiedPage].SkipOnTxCommit = true;
                            continue;
                        }

                        overflowDetector.SetPageChecked(modifiedPage);
                    }
                }

                BeforeCommitFinalization?.Invoke(this);
            }
            OnDispose?.Invoke(this);
        }
Example #26
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            Notifications.Clear();
            _buffer.Clear();

            OnDispose.InvokeSafely(this, new EventArgs());

            IsDisposed = true;
            GC.SuppressFinalize(this);
        }
Example #27
0
        /// <summary>
        ///     Releases unmanaged and - optionally - managed resources.
        /// </summary>
        public virtual void Dispose()
        {
            if (!IsDisposed)
            {
                IsDisposed = true;

                OnDispose?.Invoke(this, EventArgs.Empty);
                ThreadFactory?.Dispose();
                ModuleFactory?.Dispose();
                MemoryFactory?.Dispose();
                WindowFactory?.Dispose();
                Handle?.Close();
                GC.SuppressFinalize(this);
            }
        }
        public void Execute(OnDispose pipelineEvent)
        {
            var queue = pipelineEvent.Pipeline.State.Get <MessageQueue>("queue");

            if (queue != null)
            {
                queue.Dispose();
            }

            var journalQueue = pipelineEvent.Pipeline.State.Get <MessageQueue>("journalQueue");

            if (journalQueue != null)
            {
                journalQueue.Dispose();
            }
        }
Example #29
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    OnDispose?.Invoke();

                    SavingState();
                }

                OnDispose     = null;
                OnResult      = null;
                disposedValue = true;
            }
        }
Example #30
0
        public void Dispose()
        {
            if (_disposed.HasFlag(TxState.Disposed))
            {
                return;
            }

            try
            {
                if (!Committed && !RolledBack && Flags == TransactionFlags.ReadWrite)
                {
                    Rollback();
                }

                _disposed |= TxState.Disposed;

                PersistentContext.FreePageLocator(_pageLocator);
            }
            finally
            {
                _env.TransactionCompleted(this);

                foreach (var pagerState in _pagerStates)
                {
                    pagerState.Release();
                }

                if (JournalFiles != null)
                {
                    foreach (var journalFile in JournalFiles)
                    {
                        journalFile.Release();
                    }
                }

                _root?.Dispose();
                _freeSpaceTree?.Dispose();

                _allocator.AllocationFailed -= MarkTransactionAsFailed;
                if (_disposeAllocator)
                {
                    _allocator.Dispose();
                }

                OnDispose?.Invoke(this);
            }
        }
Example #31
0
File: Query.cs Project: sq/NDexer
        private Future <T> InternalExecuteQuery <T> (object[] parameters, Func <IFuture, T> queryFunc, bool suspendCompletion)
        {
            if (_Manager == null || _Manager.Closed)
            {
                throw new ObjectDisposedException("query");
            }

            ValidateParameters(parameters);
            var f = new Future <T>();
            var m = _Manager;

            OnDispose od = (_) => {
                Interlocked.Decrement(ref _NumberOfOutstandingQueries);
                m.NotifyQueryCompleted(f);
            };

            f.RegisterOnDispose(od);

            if (suspendCompletion)
            {
                OnComplete oc = (_) => {
                    Interlocked.Decrement(ref _NumberOfOutstandingQueries);
                    if (_.Failed)
                    {
                        m.NotifyQueryCompleted(f);
                    }
                };

                f.RegisterOnComplete(oc);
            }
            else
            {
                OnComplete oc = (_) => {
                    Interlocked.Decrement(ref _NumberOfOutstandingQueries);
                    m.NotifyQueryCompleted(f);
                };

                f.RegisterOnComplete(oc);
            }

            Interlocked.Increment(ref _NumberOfOutstandingQueries);
            Action ef = GetExecuteFunc(parameters, queryFunc, f);

            m.EnqueueQuery(f, ef);

            return(f);
        }
Example #32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TransactionScope"/> class.
        /// </summary>
        public TransactionScope(
            TransactionMode mode = TransactionMode.New,
            IsolationLevel isolation = IsolationLevel.Unspecified,
            OnDispose ondispose = OnDispose.Commit,
            ISessionScope parent = null,
            ISessionFactoryHolder holder = null,
            IThreadScopeInfo scopeinfo = null
            )
            : base(FlushAction.Config, isolation, ondispose, parent, holder, scopeinfo)
        {
            this.mode = mode;

            parentTransactionScope = ParentScope as TransactionScope;

            if (mode == TransactionMode.New) {
                if (parentTransactionScope != null) {
                    parentTransactionScope = null;
                    ParentScope = null;
                } else {
                    parentTransactionScope = null;
                }
            }
        }
Example #33
0
		/// <summary>
		/// Initializes a new instance of the <see cref="TransactionScope"/> class.
		/// </summary>
		/// <param name="mode">Whatever to create a new transaction or inherits an existing one</param>
		/// <param name="onDisposeBehavior">The on dispose behavior.</param>
		public TransactionScope(TransactionMode mode, OnDispose onDisposeBehavior) : this(mode, IsolationLevel.Unspecified, onDisposeBehavior)
		{
		}
Example #34
0
		/// <summary>
		/// Initializes a new instance of the <see cref="TransactionScope"/> class.
		/// </summary>
		/// <param name="onDisposeBehavior">The on dispose behavior.</param>
		public TransactionScope(OnDispose onDisposeBehavior) : this(TransactionMode.New, onDisposeBehavior)
		{
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="TransactionScope"/> class.
		/// </summary>
		/// <param name="mode">Determines how transactions are enrolled.</param>
		/// <param name="isolationLevel">The transaction isolation level.</param>
		/// <param name="onDisposeBehavior">Determines how the transaction behaves when the transaction is disposed.</param>
		public TransactionScope(TransactionMode mode, IsolationLevel isolationLevel, OnDispose onDisposeBehavior)
			: base(mode, isolationLevel, onDisposeBehavior)
		{
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="TransactionScope"/> class.
		/// </summary>
		/// <param name="onDisposeBehavior">Determines how the transaction behaves when the transaction is disposed.</param>
		public TransactionScope(OnDispose onDisposeBehavior)
			: base(onDisposeBehavior)
		{
		}
Example #37
0
 public void RegisterOnDispose(OnDispose handler)
 {
     _SendFuture.RegisterOnDispose(handler);
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="TransactionScope"/> class.
		/// </summary>
		/// <param name="mode">Determines how transactions are enrolled.</param>
		/// <param name="onDisposeBehavior">Determines how the transaction behaves when the transaction is disposed.</param>
		public TransactionScope(TransactionMode mode, OnDispose onDisposeBehavior)
			: base(mode, onDisposeBehavior)
		{
		}
Example #39
0
		/// <summary>
		/// Initializes a new instance of the <see cref="TransactionScope"/> class.
		/// </summary>
		/// <param name="mode">Whatever to create a new transaction or inherits an existing one</param>
		/// <param name="isolationLevel">The transaction isolation level.</param>
		/// <param name="onDisposeBehavior">The on dispose behavior.</param>
		public TransactionScope(TransactionMode mode, IsolationLevel isolationLevel, OnDispose onDisposeBehavior)
			: base(FlushAction.Auto, SessionScopeType.Transactional)
		{
			this.mode = mode;
			this.isolationLevel = isolationLevel;
			this.onDisposeBehavior = onDisposeBehavior;

			bool preferenceForTransactionScope = mode == TransactionMode.Inherits ? true : false;

			ISessionScope previousScope = ScopeUtil.FindPreviousScope(this, preferenceForTransactionScope);

			if (previousScope != null)
			{
				if (previousScope.ScopeType == SessionScopeType.Transactional)
				{
					parentTransactionScope = previousScope as TransactionScope;
				}
				else
				{
					// This is not a safe cast. Reconsider it
					parentSimpleScope = (AbstractScope) previousScope;

					foreach(ISession session in parentSimpleScope.GetSessions())
					{
						EnsureHasTransaction(session);
					}
				}
			}
		}