/// <summary> /// 生成任务。 /// </summary> /// <typeparam name="T">任务的类型。</typeparam> /// <param name="priority">任务的优先级。</param> /// <returns>生成的指定类型的任务。</returns> public T GenerateTask <T>(int priority) where T : TaskBase, new() { T task = ReferencePool.Acquire <T>(); task.Initialize(++m_Serial, priority); task.Status = TaskStatus.Waiting; task.Mono = this; task.OnGenerate(); LinkedListNode <TaskBase> current = m_Tasks.First; while (current != null) { if (task.Priority > current.Value.Priority) { break; } current = current.Next; } if (current != null) { m_Tasks.AddBefore(current, task); } else { m_Tasks.AddLast(task); } return(task); }
/// <summary> /// 例外を登録します。 /// </summary> public static void Register(Exception excp, ExceptionCategory category, string message = null, Action retry = null) { if (excp == null) { throw new ArgumentNullException("excp"); } WebException wex; if (Setting.IsInitialized && Setting.Instance.ExperienceProperty.IgnoreTimeoutError && (wex = excp as WebException) != null && wex.Status == WebExceptionStatus.Timeout) { return; } exceptions.AddLast(new ExceptionDescription(excp, category, message ?? excp.Message, retry)); OnExceptionUpdated(EventArgs.Empty); }
private static void Register(EventDescription description, bool enforceRaise = false) { // check is muted if ((description.TargetTweet != null && FilterHelper.IsMuted(description.TargetTweet.Status)) || (description.SourceUser != null && FilterHelper.IsMuted(description.SourceUser.TwitterUser)) || (description.TargetUser != null && FilterHelper.IsMuted(description.TargetUser.TwitterUser))) { return; } events.AddLast(description); OnEventChanged(EventArgs.Empty); if (enforceRaise || !Setting.Instance.NotificationProperty.IsInvisibleSomethingEnabled || !IsBlacklisted(description.SourceUser.TwitterUser)) { OnEventRegistered(new EventDescriptionEventArgs(description)); } }