Exemplo n.º 1
0
Arquivo: Idler.cs Projeto: Kidify/L4p
 private void stop_job(IdlerAction job, TimeSpan stopSpan)
 {
     using (var stopEvent = new ManualResetEvent(false))
     {
         job.Timer.Dispose(stopEvent);
         stopEvent.WaitOne(stopSpan);
     }
 }
Exemplo n.º 2
0
Arquivo: Idler.cs Projeto: Kidify/L4p
        private void add_job(IdlerAction job)
        {
            lock (this)
            {
                var list = new List<IdlerAction>(_jobs);
                list.Add(job);

                _jobs = list.ToArray();
            }
        }
Exemplo n.º 3
0
Arquivo: Idler.cs Projeto: Kidify/L4p
        private void idle_job(IdlerAction job)
        {
            int concurrentJobs = Interlocked.Increment(ref job.Mutex);

            try
            {
                if (concurrentJobs > 1)
                {
                    Interlocked.Increment(ref job.SkippedExecutions);
                    Interlocked.Increment(ref _counters.JobsSkipped);
                    return;
                }

                job.Action();
                Interlocked.Increment(ref job.SuccessfulExecutions);
                Interlocked.Increment(ref _counters.JobsExcecuted);
            }
            catch (Exception ex)
            {
                Interlocked.Increment(ref job.FailedExecutions);
                Interlocked.Increment(ref _counters.JobsFailed);
                _log.Error(ex);
            }
            finally
            {
                Interlocked.Decrement(ref job.Mutex);
            }
        }