private void DoWork(StartTasksMessage message, CancellationToken token) { Dictionary <string, List <PerformanceCounter> > taskInfo = new Dictionary <string, List <PerformanceCounter> >(); while (true) { if (token.IsCancellationRequested == true) { break; } var tasksMessage = new TasksMessage(TaskManager.GetTasksList(taskInfo)); ExecuteComplexSendOperation(message.WindowId, "Task Manager", () => tasksMessage); if (token.IsCancellationRequested) { break; } } }
public void TaskList(StartTasksMessage message) { var token = tokenSource.Token; a = Task.Factory.StartNew(() => DoWork(message, token), token); }