//protected static Func<DisposeGroupBase, List<DisposeEntry>> _locateDisposeInfos = // m => // { // if (m._disposeInfoList == null) // { // Interlocked.CompareExchange(ref m._disposeInfoList, new List<DisposeEntry>(), null); // } // return m._disposeInfoList; // }; /// <summary> /// <para>Register logic actions need to be executed when the instance is disposing</para> /// <para>注册一个销毁对象时需要执行的操作</para> /// </summary> /// <param name="newAction">Disposing action/销毁操作</param> /// <param name="needCheckInFinalizer">if set to <c>true</c> [need check in finalizer].</param> /// <param name="comment">The comment.</param> /// <param name="caller">The caller.</param> /// <param name="file">The file.</param> /// <param name="line">The line.</param> public void AddDisposeAction(Action newAction, bool needCheckInFinalizer = false, string comment = "", [CallerMemberName] string caller = "", [CallerFilePath] string file = "", [CallerLineNumber] int line = -1) { var di = new DisposeEntry { CallingCodeContext = CallingCodeContext.Create(comment, caller, file, line), Action = newAction, IsNeedCheckOnFinalizer = needCheckInFinalizer }; _disposeInfoList.Value.Add(di); }
/// <summary> /// Initializes a new instance of the <see cref="TaskExecutionWindowEventArg"/> class. /// </summary> /// <param name="executedTask">The executed task.</param> /// <param name="callingContext">The calling context.</param> public TaskExecutionWindowEventArg(Task executedTask, CallingCodeContext callingContext) { TaskWindow = executedTask.ToObservable(); CallingCodeContext = callingContext; }