public void Add(string Key, JobBaseList Value) { WaitHandle.WaitAll(this.reads); this.write.Reset(); this.Jobs.Add(Key, Value); this.write.Set(); }
public JobBaseList this[string Key] { get { //1:write信号阻止,没有调用write.Set之前 //2:reads[1]回滚到默认的初始false阻塞线程状态 //3:reads[1]释放线程阻塞 this.write.WaitOne(); this.reads[1].Reset(); JobBaseList one = this.Jobs[Key]; this.reads[1].Set(); return(one); } }
public string GetJobInfo(string jobClass, int configid) { WaitHandle.WaitAll(this.writes); this.reads[2].Reset(); string jobInfo = ""; foreach (JobBase job in this.bases) { if (configid == job.ConfigId) { jobInfo = JobBaseList.info(job); } } this.reads[2].Set(); return(jobInfo); }