public void Bind(IWorkUnit wu) { if (wu.Type == typeof(ICPUWorkUnit)) { boundTo = wu as ICPUWorkUnit; } }
public void Execute() { lock (runLock) { if (running) { throw new Exception("Job is already running"); } if (boundTo == null) { throw new ArgumentNullException("Bind"); } if (argumentDelegate == null && func == null) { throw new ArgumentNullException("Delegate"); } running = true; try { if (argumentDelegate != null) { boundTo.Execute( delegate() { argumentDelegate(argument); }); } else { boundTo.Execute(func); } } finally { boundTo = null; running = false; } } }