Пример #1
0
 public ConcurrentJob(ConcurrentJobManager mgr, Action <ConcurrentJob, object> job, ConcurrentJobCreationOptions options, string name = "")
 {
     this.State    = ConcurrentJobState.NotStarted;
     this.name     = name;
     this.job      = job;
     this.mgr      = mgr;
     this.options  = options;
     this.Progress = new ConcurrentJobProgressArgs();
 }
Пример #2
0
        public int Add(Action <ConcurrentJob, object> job, string name = "", ConcurrentJobCreationOptions options = ConcurrentJobCreationOptions.AddRunRemove, object obj = null)
        {
            var           result = -1;
            ConcurrentJob cj     = null;

            lock (AppDomain.CurrentDomain)
            {
                cj = new ConcurrentJob(this, job, options, name);
                jobs.Add(cj);

                result = jobs.Count - 1;
            }

            if (options == ConcurrentJobCreationOptions.AddRunRemove || options == ConcurrentJobCreationOptions.AddAndRun)
            {
                cj.Start(obj);
            }

            return(result);
        }