/// <summary> /// /// </summary> /// <param name="iMemberInfoHandler"></param> /// <param name="iBeforeEnqueueMemberInfo"></param> /// <param name="iTaskException"></param> public static void Register(Func <MemberInformation, bool> iMemberInfoHandler, Func <MemberInformation, bool> iBeforeEnqueueMemberInfo = null, EventHandler <UnobservedTaskExceptionEventArgs> iTaskException = null) { LibraryInformation.Initialize(); ThreadLocalInformation.Initialize(); if (_loopRecord.zzIsNotNull()) { _loopRecord.Stop(); //TODO: Wait. } if (iMemberInfoHandler.zzIsNull()) { throw new ArgumentNullException(nameof(iMemberInfoHandler), "iMemberInfoHandler.zzIsNull()"); } ThreadLocalMemberObserver.MemberInfoHandler = iMemberInfoHandler; if (iBeforeEnqueueMemberInfo.zzIsNotNull()) { ThreadLocalMemberObserver.BeforeEnqueueMemberInfo = iBeforeEnqueueMemberInfo; } TaskScheduler.UnobservedTaskException += (iTaskException.zzIsNull() ? ThreadLocalMemberObserver.UnobservedTaskException : iTaskException); _loopRecord = LoopObserver.SpinUntilInBackground(memberInfoHandler, TaskCreationOptions.LongRunning); //TODO: Test self. }
static Starter() { _loopRecord = null; }