public void Attach(string taskId, ITask task, object executionState) { if (string.IsNullOrEmpty(taskId)) { throw new ArgumentException("taskId"); } if (tasks.ContainsKey(taskId)) { throw new ArgumentException("taskId已存在"); } lock (locker) { var taskExecutor = new TaskExecutor(task, executionState); tasks[taskId] = taskExecutor; taskExecutor.Start(); } }