TraceFrameEvent() static private méthode

static private TraceFrameEvent ( TraceFrameEventType eventType, TraceFrame traceFrame ) : void
eventType TraceFrameEventType
traceFrame TraceFrame
Résultat void
Exemple #1
0
        internal TraceFrame(string message, MethodBase caller, GenerateTraceFrameEventMessages frameEventMessagesGenerateMode)
        {
            Message = message;
            Caller  = caller;
            FrameEventMessagesGenerateMode = frameEventMessagesGenerateMode;

            if (RootTraceFrame == null)
            {
                RootTraceFrame = this;
            }
            else
            {
                TraceFrame lastTraceFrame = RootTraceFrame;

                while (lastTraceFrame._nextTraceFrame != null)
                {
                    lastTraceFrame = lastTraceFrame._nextTraceFrame;
                }

                lastTraceFrame._nextTraceFrame = this;
            }

            if (FrameEventMessagesGenerateMode == GenerateTraceFrameEventMessages.GenerateAll)
            {
                TraceHelper.TraceFrameEvent(TraceFrameEventType.Started, this);
            }
        }
Exemple #2
0
        private void Dispose(bool calledByFinalizer)
        {
            if (_isUnderDisposal == false)
            {
                _isUnderDisposal = true;

                TraceFrame tf = RootTraceFrame;

                if (tf == this)
                {
                    // This is the root
                    if (tf._nextTraceFrame != null)
                    {
                        if (FrameEventMessagesGenerateMode == GenerateTraceFrameEventMessages.GenerateAll || FrameEventMessagesGenerateMode == GenerateTraceFrameEventMessages.ErrorsOnly)
                        {
                            TraceHelper.TraceFrameEvent(TraceFrameEventType.WrongDisposeOrder, this);
                        }
                    }

                    RootTraceFrame = null;
                }
                else
                {
                    // This is not the root

                    while (tf == null || tf._nextTraceFrame != this)
                    {
                        tf = tf._nextTraceFrame;
                    }

                    // We went down the list, but cannot found ourselves -> must never happen.
                    System.Diagnostics.Debug.Assert(tf != null);

                    // Now "tf" points to my parent

                    // I have children - the developer calls the Dispose in wrong order...
                    if (_nextTraceFrame != null)
                    {
                        if (FrameEventMessagesGenerateMode == GenerateTraceFrameEventMessages.GenerateAll || FrameEventMessagesGenerateMode == GenerateTraceFrameEventMessages.ErrorsOnly)
                        {
                            TraceHelper.TraceFrameEvent(TraceFrameEventType.WrongDisposeOrder, this);
                        }
                    }

                    // Ask my parent to kill me. Not PC, but works.
                    tf._nextTraceFrame = null;
                }

                if (FrameEventMessagesGenerateMode == GenerateTraceFrameEventMessages.GenerateAll)
                {
                    TraceHelper.TraceFrameEvent(TraceFrameEventType.Finished, this);
                }

                if (!calledByFinalizer)
                {
                    GC.SuppressFinalize(this);
                }
            }
        }