示例#1
0
 public void Push(object message)
 {
     if (ShouldDispose())
     {
         _disposeCount++;
         Disposed.Raise(this);
     }
 }
示例#2
0
        public void Dispose()
        {
            var args = new EventArgs <T>(this.InternalObject);

            disposed(this, args);

            if (Disposed != null)
            {
                Disposed.Raise(this, args.Value);
            }
        }
示例#3
0
        public virtual void Dispose()
        {
            if (isDisposed)
            {
                var message = string.Format("Object already disposed: {0}", this);
                throw new ObjectDisposedException(message);
            }

            isDisposed = true;

            Disposed.Raise(this);
        }
示例#4
0
 private void OnSubscriptionDisposed(object sender, EventArgs e)
 {
     try
     {
         _rwLock.EnterWriteLock();
         _subscriptions.Remove(sender as IDisposableSubscription);
         Disposed.Raise(sender);
     }
     finally
     {
         _rwLock.ExitWriteLock();
     }
 }
示例#5
0
文件: Tool.cs 项目: wtfcolt/game
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            GC.SuppressFinalize(this);
            _isDisposed = true;

            Dispose(true);

            if (Disposed != null)
            {
                Disposed.Raise(this, EventArgs.Empty);
            }
        }
示例#6
0
        /// <summary>
        /// Immediately terminates the <see cref="IParticleEffect"/> and all <see cref="IParticleEffect"/>s in it.
        /// </summary>
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }

            _isDisposed = true;

            // Dispose all emitters
            foreach (var e in _emitters)
            {
                e.Dispose();
            }

            if (Disposed != null)
            {
                Disposed.Raise(this, EventArgs.Empty);
            }
        }
        private void Dispose(bool disposing)
        {
            if (m_isDisposed)
            {
                return;
            }

            Disposing.Raise(this, EventArgs.Empty);
            if (disposing)
            {
                DisposeManagedResources();
            }

            DisposeUnmanagedResources();
            Disposed.Raise(this, EventArgs.Empty);

            Disposing.Dispose();
            Disposed.Dispose();
            m_isDisposed = true;
        }
示例#8
0
        /// <summary>
        /// Disposes of the <see cref="Entity"/>.
        /// </summary>
        public void Dispose()
        {
            // Check if the Entity has already been disposed
            if (IsDisposed)
            {
                return;
            }

            GC.SuppressFinalize(this);

            _isDisposed = true;

            // Notify listeners that the Entity is being disposed
            if (Disposed != null)
            {
                Disposed.Raise(this, EventArgs.Empty);
            }

            // Handle the disposing
            HandleDispose(true);
        }
示例#9
0
        /// <summary>
        /// Immediately terminates the <see cref="IParticleEmitter"/> and all <see cref="Particle"/>s in it.
        /// </summary>
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }

            _isDisposed = true;

            // Dispose the particles so they can be used again
            foreach (var particle in _particles)
            {
                if (particle != null && !particle.IsDisposed)
                {
                    particle.Dispose();
                }
            }

            if (Disposed != null)
            {
                Disposed.Raise(this, EventArgs.Empty);
            }
        }
示例#10
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public virtual void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            IsDisposed = true;

            try
            {
                // Clear the atlas (if one exists)
                if (_atlas != null && !_atlas.IsDisposed)
                {
                    try
                    {
                        _atlas.Dispose();
                    }
                    catch (Exception ex)
                    {
                        const string errmsg = "Failed to dispose `{0}`. Exception: {1}";
                        if (log.IsWarnEnabled)
                        {
                            log.WarnFormat(errmsg, _atlas, ex);
                        }
                        Debug.Fail(string.Format(errmsg, _atlas, ex));
                    }
                }

                if (_mapAtlases != null)
                {
                    // Clear the map atlas images
                    foreach (var atlas in _mapAtlases)
                    {
                        try
                        {
                            if (atlas != null && !atlas.IsDisposed)
                            {
                                atlas.Dispose();
                            }
                        }
                        catch (Exception ex)
                        {
                            const string errmsg = "Failed to dispose `{0}`. Exception: {1}";
                            if (log.IsWarnEnabled)
                            {
                                log.WarnFormat(errmsg, atlas, ex);
                            }
                            Debug.Fail(string.Format(errmsg, atlas, ex));
                        }
                    }

                    // Clear the atlas list
                    _mapAtlases.Clear();
                }
            }
            catch (Exception ex)
            {
                const string errmsg = "Failed to dispose `{0}`. Exception: {1}";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, this, ex);
                }
                Debug.Fail(string.Format(errmsg, this, ex));
            }

            if (Disposed != null)
            {
                Disposed.Raise(this, EventArgs.Empty);
            }
        }
示例#11
0
 public void Dispose()
 {
     IsDisposed = true;
     Disposed.Raise(this);
 }
示例#12
0
 private void raiseDispose()
 {
     IsDisposed = true;
     action     = null;
     Disposed.Raise(this);
 }
示例#13
0
 public void Dispose()
 {
     Disposed.Raise(this, this.Handle);
 }