コード例 #1
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        private void Dispose(bool disposing)
        {
            if (m_Disposed)
            {
                return;
            }

            if (disposing)
            {
                m_Stopwatch  = null;
                m_OnDispose  = null;
                m_MethodName = null;
                m_Disposed   = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StopwatchContext"/> class.
        /// </summary>
        /// <param name="stopwatch">The stopwatch.</param>
        /// <param name="onDispose">The configuration dispose.</param>
        public StopwatchContext(IStopwatch stopwatch, StopwatchContextOnDispose onDispose)
        {
            if (stopwatch == null)
            {
                throw new ArgumentNullException("stopwatch");
            }

            if (onDispose == null)
            {
                throw new ArgumentNullException("onDispose");
            }

            m_Stopwatch = stopwatch;
            m_OnDispose = onDispose;

            StackFrame frame  = new StackFrame(1, false);
            MethodBase method = frame.GetMethod();

            m_MethodName = method.ToString();

            m_Stopwatch.Reset();
            m_Stopwatch.Start();
        }