/// <summary> /// Frees all resources held by this object, immediately (rather than waiting for Garbage Collection). This can provide a performance increase and avoid /// memory congestion on objects that hold many or "expensive" (large) external resources. /// </summary> /// <remarks> /// First fires the Disposing event, which could cancel this operation. When not canceled, calls the <see cref="Dispose(bool)"/> method, which should be /// overridden in inheriting classes to release their local resources. Finally fires the Disposed event. Use the IsDisposing and IsDisposed properties to /// avoid using objects that are about to or have been disposed. /// </remarks> public void Dispose() { // Dispose only once if (IsDisposing || IsDisposed) { return; } IsDisposing = true; try { // Fire disposing event Disposing?.Invoke(this, EventArgs.Empty); } finally { try { // Full managed dispose Dispose(true); } finally { // Do not finalize GC.SuppressFinalize(this); } } }
protected virtual void Dispose(bool disposing) { if (!IsDisposed) { if (Disposing != null) { Disposing.Invoke(this, null); } foreach (SoundEffect se in INTERNAL_sounds) { if (se != null) { se.Dispose(); } } INTERNAL_baseEngine.INTERNAL_removeWaveBank(INTERNAL_name); INTERNAL_sounds = null; if (INTERNAL_waveBankReader != null) { INTERNAL_waveBankReader.Close(); INTERNAL_waveBankReader = null; } IsDisposed = true; IsPrepared = false; } }
public void Dispose() { Disposing?.Invoke(this, EventArgs.Empty); Dispose(true); GC.SuppressFinalize(this); }
protected virtual void Dispose(bool disposing) { lock (_disposeLock) { if (_disposed) { return; } _disposed = true; //set true before event call to prevent loop if (disposing) { Disposing?.Invoke(this, EventArgs.Empty); if (_stream1 != null) { _stream1.Dispose(); } if (_stream2 != null) { _stream2.Dispose(); } } } }
public void Dispose() { if (!IsDisposed) { if (Disposing != null) { Disposing.Invoke(this, null); } foreach (AudioCategory curCategory in INTERNAL_categories) { curCategory.Stop(AudioStopOptions.Immediate); } INTERNAL_categories.Clear(); foreach (KeyValuePair <long, DSPPreset> curDSP in INTERNAL_dspPresets) { curDSP.Value.Dispose(); } INTERNAL_dspPresets.Clear(); INTERNAL_dspParameters.Clear(); INTERNAL_variables.Clear(); INTERNAL_RPCs.Clear(); AudioDevice.ALDevice.DeleteFilter(Filter); IsDisposed = true; } }
/// <summary> /// Abort this transaction and deallocate all resources associated with it (including databases). /// </summary> /// <param name="disposing">True if called from Dispose.</param> protected virtual void Dispose(bool disposing) { if (_handle == IntPtr.Zero) { return; } Environment.Disposing -= Dispose; if (ParentTransaction != null) { ParentTransaction.Disposing -= Dispose; ParentTransaction.StateChanging -= OnParentStateChanging; } Disposing?.Invoke(); if (State == LightningTransactionState.Active || State == LightningTransactionState.Reseted) { Abort(); } _handle = IntPtr.Zero; if (disposing) { GC.SuppressFinalize(this); } }
/// <summary> /// Notifies listeners that the instance is being disposed. /// </summary> protected virtual void OnDisposing() { if (Disposing != null) { Disposing.Invoke(this, EventArgs.Empty); } }
public virtual void Dispose() { if (_disposed) { return; } if (!_disposed) { try { BaseStream?.Close(); _stoken.BaseStream = null; _disposed = true; } catch (Exception ex) { LoggerService.WriteException(ex); } try { Disposing?.Invoke(this, EventArgs.Empty); } catch (Exception ex) { LoggerService.WriteException(ex); } } }
public virtual void Dispose() { if (!MessageModalProxyExtensions.IsMessageModalPresent(this.Selenium)) { if (!AvoidClose) { try { if (this.Element.IsStale()) { return; } var button = this.CloseButton.TryFind(); if (button != null && button.Displayed) { button.Click(); } } catch (ElementNotVisibleException) { } catch (StaleElementReferenceException) { } this.WaitNotVisible(); } } Disposing?.Invoke(OkPressed); }
internal void Dispose(bool disposing) { if (_disposed) { return; } Disposing?.Invoke(this, EventArgs.Empty); _disposed = true; switch (_dcType) { case DeviceContextType.Information: case DeviceContextType.NamedDevice: Interop.Gdi32.DeleteDC(new HandleRef(this, _hDC)); _hDC = IntPtr.Zero; break; case DeviceContextType.Memory: Interop.Gdi32.DeleteDC(new HandleRef(this, _hDC)); _hDC = IntPtr.Zero; break; // case DeviceContextType.Metafile: - not yet supported. case DeviceContextType.Unknown: default: return; // do nothing, the hdc is not owned by this object. // in this case it is ok if disposed throught finalization. } DbgUtil.AssertFinalization(this, disposing); }
public void Dispose() { if (!IsDisposed) { if (Disposing != null) { Disposing.Invoke(this, null); } if (INTERNAL_instancePool != null) { foreach (SoundEffectInstance sfi in INTERNAL_instancePool) { sfi.Dispose(); } INTERNAL_instancePool.Clear(); INTERNAL_instanceVolumes.Clear(); INTERNAL_instancePitches.Clear(); INTERNAL_rpcTrackVolumes.Clear(); INTERNAL_rpcTrackPitches.Clear(); INTERNAL_timer.Stop(); } INTERNAL_category.INTERNAL_removeActiveCue(this); IsDisposed = true; } }
public void Dispose() { if (!IsDisposed) { if (Disposing != null) { Disposing.Invoke(this, null); } if (INTERNAL_instancePool != null) { foreach (SoundEffectInstance sfi in INTERNAL_instancePool) { sfi.Dispose(); } INTERNAL_instancePool.Clear(); INTERNAL_instanceVolumes.Clear(); INTERNAL_instancePitches.Clear(); INTERNAL_rpcTrackVolumes.Clear(); INTERNAL_rpcTrackPitches.Clear(); } KillCue(); IsDisposed = true; // IXACTCue* no longer exists, these should all be false IsStopped = false; IsCreated = false; IsPrepared = false; } }
//public void CloseDiscardChanges() not in use //{ // this.CloseButton.Find().Click(); // Selenium.ConsumeAlert(); // this.WaitNotVisible(); //} public override void Dispose() { if (!AvoidClose) { string?confirmationMessage = null; Selenium.Wait(() => { if (this.Element.IsStale()) { return(true); } if (TryToClose()) { return(true); } if (MessageModalProxyExtensions.IsMessageModalPresent(this.Selenium)) { var alert = MessageModalProxyExtensions.GetMessageModal(this.Selenium) !; alert.Click(MessageModalButton.Yes); } return(false); }, () => "popup {0} to disapear with or without confirmation".FormatWith(this.Element)); if (confirmationMessage != null) { throw new InvalidOperationException(confirmationMessage); } } Disposing?.Invoke(this.OkPressed); }
protected virtual void OnDisposing(EventArgs e) { if (Disposing != null) { Disposing.Invoke(this, e); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> #pragma warning disable CA1063 // Implement IDisposable Correctly private void Dispose(bool disposing) #pragma warning restore CA1063 // Implement IDisposable Correctly { // If already 0, return. if (!AtomicHelper.DecrementIfGreaterThan(ref refCounter_, 0)) { Debug.Assert(RefCount == 0); return; } var currRef = RefCount; if (currRef == 0 && !IsDisposed) { if (Interlocked.Increment(ref disposeCount_) == 1) { AddBackToPool = null; Disposing?.Invoke(this, disposing ? BoolEventArgs.TrueArgs : BoolEventArgs.FalseArgs); Disposing = null; OnDispose(disposing); //GC.SuppressFinalize(this); IsDisposed = true; Disposed?.Invoke(this, disposing ? BoolEventArgs.TrueArgs : BoolEventArgs.FalseArgs); Disposed = null; } } else if (currRef == 1) { AddBackToPool?.Invoke(this); } }
public virtual void Dispose() { if (!_isDisposed) { Disposing?.Invoke(this, new EventArgs()); } _isDisposed = true; }
protected internal virtual void OnDisposing(object sender, IDisposingEventArgs <TService> e) { if (!Enabled) { return; } Disposing?.Invoke(sender, e); }
public void Dispose() { if (!_disposedValue) { Disposing?.Invoke(this, EventArgs.Empty); _disposedValue = true; } }
void fireDisposingEvent() { if (Disposing != null) { try { Disposing.Invoke(this, new EventArgs()); } catch { } } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { Disposing?.Invoke(); } }
public async ValueTask DisposeAsync() { await Task.Delay(1); IsAsyncDisposed = true; Disposing?.Invoke(this, EventArgs.Empty); }
private void RaiseDisposing(EventArgs empty) { if (empty == null) { throw new ArgumentNullException(nameof(empty)); } Disposing?.Invoke(this, empty); }
/// <inheritdoc /> /// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (!isDisposed) { isDisposed = true; Disposing?.Invoke(this, EventArgs.Empty); DisposeCore(); } }
protected virtual void Dispose(bool _) { ++m_resize_issue; Disposing?.Invoke(this, EventArgs.Empty); Source = null; D3DImage = null !; Window = null !; View3d = null !; }
public void Dispose() { if (Disposing != null) { Disposing.Invoke(); } IDisposableUtil.DisposeIfNotNull(dialogManager); }
protected virtual void Dispose(bool isDisposing) { if (Disposing != null) { Disposing.Invoke(this, EventArgs.Empty); } IsDisposed = true; }
internal void Dispose(bool disposing) { if (disposed) { return; } Disposing?.Invoke(this, EventArgs.Empty); disposed = true; DisposeFont(disposing); switch (dcType) { case DeviceContextType.Display: Debug.Assert(disposing, "WARNING: Finalizing a Display DeviceContext.\r\nReleaseDC may fail when not called from the same thread GetDC was called from."); ((IDeviceContext)this).ReleaseHdc(); break; case DeviceContextType.Information: case DeviceContextType.NamedDevice: // CreateDC and CreateIC add an HDC handle to the HandleCollector; to remove it properly we need // to call DeleteHDC. #if TRACK_HDC Debug.WriteLine(DbgUtil.StackTraceToStr(String.Format("DC.DeleteHDC(hdc=0x{0:x8})", unchecked ((int)this.hDC)))); #endif UnsafeNativeMethods.DeleteDC(new HandleRef(this, hDC)); hDC = IntPtr.Zero; break; case DeviceContextType.Memory: // CreatCompatibleDC adds a GDI handle to HandleCollector, to remove it properly we need to call // DeleteDC. #if TRACK_HDC Debug.WriteLine(DbgUtil.StackTraceToStr(String.Format("DC.DeleteDC(hdc=0x{0:x8})", unchecked ((int)this.hDC)))); #endif UnsafeNativeMethods.DeleteDC(new HandleRef(this, hDC)); hDC = IntPtr.Zero; break; case DeviceContextType.Unknown: default: return; // do nothing, the hdc is not owned by this object. // in this case it is ok if disposed throught finalization. } DbgUtil.AssertFinalization(this, disposing); }
protected override void Dispose(bool disposing) { if (disposing & !isDisposing) { isDisposing = true; Disposing?.Invoke(null, EventArgs.Empty); base.Dispose(disposing); } }
void fireDisposingEvent(EventObject Source) { if (Disposing != null) { try { Disposing.Invoke(this, new EventObjectForwarder(Source)); } catch { } } }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { Disposing?.Invoke(this, EventArgs.Empty); Context.Dispose(); } } this.disposed = true; }