private void onTaskComplete(Task taskCompleted) { if (TaskComplete != null) TaskComplete(this, taskCompleted); }
private void onTaskSentToClient(Task task) { if (TaskSentToClient != null) TaskSentToClient(this, task); }
public void UploadResults(Task finishedTask) { workerMaster.JoinCompletedTask(finishedTask); }
void master_TaskComplete(object sender, Task taskCompleted) { // propagate master's event onTaskComplete(taskCompleted); }
/// <summary> /// Joins completed tasks with other completed tasks. /// </summary> public abstract void JoinCompletedTask(Task taskCompleted);
protected void onTaskComplete(Task taskCompleted) { if (TaskComplete != null) TaskComplete(this, taskCompleted); }
private void raytracerMaster_TaskComplete(object sender, Task task) { try { // TODO : make conversion Task <-> rect extension metods in a separate file Rectangle rect = RaytracingSlave.getRectFromTask(task, sceneSettings.ImageWidth, sceneSettings.ImageHeight); GraphicsHelper.Render((Lucid.Raytracing.Color[])task.Result, rect, (Bitmap)pbResult.Image); pbResult.Refresh(); //Log.WriteMessage("Task complete from client."); } catch (Exception ex) { Inv.Common.Exceptions.ExceptionDialog(ex.Message); } }
void lucidServer_TaskSentToClient(object sender, Task taskSent) { try { //Log.WriteMessage(string.Format("Task sent to client.")); if (!stopWatch.IsRunning && taskSent != null) { // start stopwatch on first task stopWatch.Reset(); stopWatch.Start(); } } catch (Exception ex) { Inv.Common.Exceptions.ExceptionDialog(ex.Message); } }
public override Task GetNextTask() { if (ImageWidth == 0 || ImageHeight == 0) throw new InvalidOperationException("ImageWidth and ImageHeight must be set."); // simulation of while loop // test at the beginning if (curY >= ImageHeight) { if (!Completed) { // look if there are any pending tasks return tasksNotCompleted.First(); } else { // no pending tasks return null; } } // processing Rectangle taskRect = new Rectangle(curX, curY, taskRectWidht, taskRectHeight); taskRect = clipRect(taskRect, ImageWidth, ImageHeight); Task result = new Task { Start = getPixelNoFromXY(taskRect.Left, taskRect.Top), End = getPixelNoFromXY(taskRect.Left + taskRect.Width - 1, taskRect.Top + taskRect.Height - 1), Number = ++curTaskNo }; // maintenance code at the end curX += taskRectWidht; if (curX >= ImageWidth) { curX = 0; curY += taskRectHeight; } if (curY >= ImageHeight) { // finished first loop through the image wholeWorkSent = true; } // result from processing tasksNotCompleted.Add(result); return result; }
public override void JoinCompletedTask(Task completedTask) { // delete completed task from list of pending tasks tasksNotCompleted.RemoveAll( (Task t) => (t.Start == completedTask.Start && t.End == completedTask.End)); onTaskComplete(completedTask); if (wholeWorkSent && tasksNotCompleted.Count == 0) { // everything sent and nothing remaining unsolved Completed = true; onComplete(); } }
public abstract void RunTask(Task task);