Esempio n. 1
0
            public Subscription(SubjectSlim <T> subject, IObserver <T> observer)
            {
#if DEBUG
                _allocStackTrace = new StackTrace();
#endif

                if (subject == null)
                {
                    throw new ArgumentNullException(nameof(subject));
                }
                if (observer == null)
                {
                    throw new ArgumentNullException(nameof(observer));
                }

                _subject  = subject;
                _observer = observer;
            }
Esempio n. 2
0
            protected virtual void Dispose(bool disposing)
            {
                try
                {
                    var subject  = _subject;
                    var observer = _observer;

                    if (subject != null && observer != null)
                    {
                        subject.Unsubscribe(observer);
                    }

                    _subject  = null;
                    _observer = null;
                }
                catch (Exception ex) when(!disposing)
                {
                    Log.Source.TraceEvent(TraceEventType.Error, 0, Resources.LogMessages.Shared_ExceptionDuringFinalization, ex);
                }
            }