예제 #1
0
 private void onTaskComplete(Task taskCompleted)
 {
     if (TaskComplete != null)
         TaskComplete(this, taskCompleted);
 }
예제 #2
0
 private void onTaskSentToClient(Task task)
 {
     if (TaskSentToClient != null)
         TaskSentToClient(this, task);
 }
예제 #3
0
 public void UploadResults(Task finishedTask)
 {
     workerMaster.JoinCompletedTask(finishedTask);
 }
예제 #4
0
 void master_TaskComplete(object sender, Task taskCompleted)
 {
     // propagate master's event
     onTaskComplete(taskCompleted);
 }
예제 #5
0
 /// <summary>
 /// Joins completed tasks with other completed tasks.
 /// </summary>
 public abstract void JoinCompletedTask(Task taskCompleted);
예제 #6
0
 protected void onTaskComplete(Task taskCompleted)
 {
     if (TaskComplete != null)
         TaskComplete(this, taskCompleted);
 }
예제 #7
0
 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);
     }
 }
예제 #8
0
 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);
     }
 }
예제 #9
0
        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;
        }
예제 #10
0
        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();
            }
        }
예제 #11
0
 public abstract void RunTask(Task task);