示例#1
0
        void _jobResultReciver_OnJobResultRecive(Quax.JobResult result)
        {
            // Inform JobDispatcher for this event
            _jobDispatcher.JobResultRecived(result);

            // Raise "Quax.JobResultRecive" event
            EventExtensions.Raise(JobResultRecive, new object[] { result });
        }
示例#2
0
            public void JobResultRecived(Quax.JobResult result)
            {
                // This method is invoked by "Quax" object whenever a result recived from a worker
                // "Quax" object is informed by "JobResultReciver" object

                // Update pending jobs table
                PendingJobRecord record = null;
                Job pendingJob          = null;

                lock (_pendingJobs) {
                    for (int i = 0; i < _pendingJobs.Count; i++)
                    {
                        if (_pendingJobs[i].Worker.ID == result.WorkerID)
                        {
                            for (int j = 0; j < _pendingJobs[i].Jobs.Count; j++)
                            {
                                if (_pendingJobs[i].Jobs[j].ID == result.JobID)
                                {
                                    record     = _pendingJobs[i];
                                    pendingJob = _pendingJobs[i].Jobs[j];
                                }
                            }
                        }
                    }

                    if (pendingJob != null)
                    {
                        // Pending job found, we should remove it from table and update its fields
                        record.Jobs.Remove(pendingJob);
                        record.ExpectedTimeToComplete -= pendingJob.ExpectedTimeToComplete;
                        record.MaxTimeToComplete      -= pendingJob.MaxTimeToComplete;

                        // If record has no associated job, we can remove it from table
                        if (record.Jobs.Count == 0)
                        {
                            _pendingJobs.Remove(record);
                        }
                    }

                    /* If (pendingJob == null) ===> pending job is removed in the past (2 job result
                     *    is recived for 1 unique job by to diffrent worker!) */
                }
            }