public static void Unregister(IThreadSafeTask tfTask, int token) { if (WorkScheduler.Instance != null) { WorkScheduler.Instance.unregister(tfTask, token); } }
public async Task DeleteProjectsUnreferencedByTimeEntriesInInaccessibleWorkspace() { var accessibleWorkspace = new MockWorkspace(1000, isInaccessible: false); var inaccessibleWorkspace = new MockWorkspace(2000, isInaccessible: true); var project1 = new MockProject(101, accessibleWorkspace, syncStatus: SyncStatus.InSync); var project2 = new MockProject(102, accessibleWorkspace, syncStatus: SyncStatus.RefetchingNeeded); var project3 = new MockProject(201, inaccessibleWorkspace, syncStatus: SyncStatus.InSync); var project4 = new MockProject(202, inaccessibleWorkspace, syncStatus: SyncStatus.SyncNeeded); var project5 = new MockProject(203, inaccessibleWorkspace, syncStatus: SyncStatus.SyncNeeded); var project6 = new MockProject(204, inaccessibleWorkspace, syncStatus: SyncStatus.InSync); var project7 = new MockProject(205, inaccessibleWorkspace, syncStatus: SyncStatus.InSync); var te1 = new MockTimeEntry(10001, accessibleWorkspace, project: project1, syncStatus: SyncStatus.InSync); var te2 = new MockTimeEntry(10002, accessibleWorkspace, project: project2, syncStatus: SyncStatus.SyncNeeded); var te3 = new MockTimeEntry(20001, inaccessibleWorkspace, project: project3, syncStatus: SyncStatus.InSync); var te4 = new MockTimeEntry(20002, inaccessibleWorkspace, project: project4, syncStatus: SyncStatus.SyncNeeded); var te5 = new MockTimeEntry(20003, inaccessibleWorkspace, project: project4, syncStatus: SyncStatus.SyncFailed); var te6 = new MockTimeEntry(20004, inaccessibleWorkspace, project: project4, syncStatus: SyncStatus.InSync); var projects = new[] { project1, project2, project3, project4, project5, project6, project7 }; var tasks = new IThreadSafeTask[] { }; var timeEntries = new[] { te1, te2, te3, te4, te5, te6 }; var unreferencedProjects = new[] { project6, project7 }; var neededProjects = projects.Where(project => !unreferencedProjects.Contains(project)); configureDataSource(projects, tasks, timeEntries); await state.Start().SingleAsync(); projectsDataSource.Received().DeleteAll(Arg.Is <IEnumerable <IThreadSafeProject> >(arg => arg.All(project => unreferencedProjects.Contains(project)) && arg.None(project => neededProjects.Contains(project)))); }
public void Unregister(IThreadSafeTask tfTask) { WorkSchedulerBatch.MainThreadUpdating = true; if (this.tfTasks.Count > 0) { int num = this.tfTasks.LastIndexOf(tfTask); if (num >= 0) { this.tfTasks.RemoveAt(num); } } if (tfTask.ShouldDoMainThreadRefresh) { tfTask.ShouldDoMainThreadRefresh = false; if (this.tfTasksChanged.Count > 0) { int num2 = this.tfTasksChanged.LastIndexOf(tfTask); if (num2 >= 0) { this.tfTasksChanged.RemoveAt(num2); } } } WorkSchedulerBatch.MainThreadUpdating = false; }
public void unregister(IThreadSafeTask tfTask, int token) { int num = Mathf.Clamp(token / this.GridSize, 0, this.GridSize - 1); int num2 = Mathf.Clamp(token - num * this.GridSize, 0, this.GridSize - 1); this.schedulers[num, num2].Unregister(tfTask); }
public void DoThreadSafeWorkTryCatch(bool autoUnregister = false) { int i = this.tfTasks.Count - 1; while (i >= 0) { IThreadSafeTask threadSafeTask = this.tfTasks[i]; try { bool shouldDoMainThreadRefresh = threadSafeTask.ShouldDoMainThreadRefresh; threadSafeTask.ThreadedRefresh(); if (shouldDoMainThreadRefresh != threadSafeTask.ShouldDoMainThreadRefresh) { if (shouldDoMainThreadRefresh) { this.tfTasksChanged.Remove(threadSafeTask); } else { this.tfTasksChanged.Add(threadSafeTask); } } } catch { } i--; if (autoUnregister) { this.tfTasks.RemoveAt(this.iterator); } } }
public int register(IThreadSafeTask tfTask, Vector3 position, bool force) { int num = Mathf.Clamp(this.WorldToGridX(position.x), 0, this.GridSize - 1); int num2 = Mathf.Clamp(this.WorldToGridY(position.z), 0, this.GridSize - 1); this.schedulers[num, num2].Register(tfTask, force); return(num * this.GridSize + num2); }
public int DoWorkNoTry(long maxTicks, bool autoUnregister = false) { int count = this.tfTasksChanged.Count; long num = maxTicks * (long)(3 + count / 10); int num2 = 0; this.stopwatch.Stop(); this.stopwatch.Reset(); this.stopwatch.Start(); while (num2 < count && (this.stopwatch.ElapsedTicks < num || WorkScheduler.FullCycle)) { if (this.tfTasksChanged.Count == 0) { break; } IThreadSafeTask threadSafeTask = this.tfTasksChanged[0]; try { threadSafeTask.ShouldDoMainThreadRefresh = false; threadSafeTask.MainThreadRefresh(); } catch { } num2++; if (autoUnregister) { this.Unregister(threadSafeTask); } else { this.tfTasksChanged.Remove(threadSafeTask); } } count = this.tasks.Count; num2 = 0; this.stopwatch.Stop(); this.stopwatch.Reset(); this.stopwatch.Start(); while (num2 < count && (this.stopwatch.ElapsedTicks < maxTicks || WorkScheduler.FullCycle)) { int count2 = this.tasks.Count; if (this.iterator < 0) { this.iterator += count2; } this.iterator = (this.iterator + count2) % count2; this.tasks[this.iterator](); num2++; if (autoUnregister) { this.tasks.RemoveAt(this.iterator); } this.iterator--; } this.stopwatch.Stop(); return(num2); }
public TaskSuggestion(IThreadSafeTask task) { TaskId = task.Id; Name = task.Name; ProjectId = task.ProjectId; WorkspaceId = task.WorkspaceId; ProjectName = task.Project?.Name ?? ""; ProjectColor = task.Project?.Color ?? ""; }
public void Register(IThreadSafeTask tfTask, bool force = false) { WorkSchedulerBatch.MainThreadUpdating = true; if (force || !this.tfTasks.Contains(tfTask)) { this.tfTasks.Add(tfTask); } WorkSchedulerBatch.MainThreadUpdating = false; }
private static IThreadSafeTimeEntry createTimeEntry( DateTimeOffset start, IThreadSafeWorkspace workspace, string description, long duration, IThreadSafeProject project = null, IThreadSafeTask task = null, IThreadSafeTag[] tags = null, bool billable = false) => new MockTimeEntry { Start = start, Workspace = workspace, WorkspaceId = workspace.Id, Description = description, Duration = duration, Project = project, ProjectId = project?.Id, Task = task, TaskId = task?.Id, Billable = billable, Tags = tags ?? Array.Empty <IThreadSafeTag>(), TagIds = tags?.Select(tag => tag.Id) ?? new long[0] };
public MockTimeEntry( long id, IThreadSafeWorkspace workspace, DateTimeOffset?start = null, long?duration = null, IThreadSafeProject project = null, IThreadSafeTask task = null, IEnumerable <IThreadSafeTag> tags = null, SyncStatus syncStatus = SyncStatus.InSync ) : this() { Id = id; Workspace = workspace; WorkspaceId = workspace.Id; Start = start ?? default(DateTimeOffset); Duration = duration; Project = project; ProjectId = project?.Id; Task = task; TaskId = task?.Id; Tags = tags; TagIds = tags?.Select(tag => tag.Id); SyncStatus = syncStatus; }
public static bool IsPlaceholder(this IThreadSafeTask task) => task?.SyncStatus == SyncStatus.RefetchingNeeded;
public static int Register(IThreadSafeTask tfTask, Vector3 position, bool force = false) { WorkScheduler.CheckConfig(); return(WorkScheduler.Instance.register(tfTask, position, force)); }
private ProjectSpan(IThreadSafeProject project, IThreadSafeTask task) : this(task.ProjectId, project.Name, project.Color, task.Id, task.Name) { }
public ProjectSpan(IThreadSafeTask task) : this(task.Project, task) { }