コード例 #1
0
ファイル: Jobs.cs プロジェクト: ZhangVic/asp1110git
 public void Start()
 {
     Interlocked.Increment(ref _instancesOfParent);
     lock (this.jobList.SyncRoot)
     {
         if (this.jobList.Count == 0)
         {
             XmlNode configSection = HiConfiguration.GetConfig().GetConfigSection("Hishop/Jobs");
             bool flag = true;
             XmlAttribute attribute = configSection.Attributes["singleThread"];
             if (((attribute != null) && !string.IsNullOrEmpty(attribute.Value)) && (string.Compare(attribute.Value, "false", true, CultureInfo.InvariantCulture) == 0))
             {
                 flag = false;
             }
             XmlAttribute attribute2 = configSection.Attributes["minutes"];
             if ((attribute2 != null) && !string.IsNullOrEmpty(attribute2.Value))
             {
                 int result = 1;
                 if (int.TryParse(attribute2.Value, out result))
                 {
                     this.Interval = result * 0xea60;
                 }
             }
             foreach (XmlNode node2 in configSection.ChildNodes)
             {
                 if ((configSection.NodeType != XmlNodeType.Comment) && (node2.NodeType != XmlNodeType.Comment))
                 {
                     XmlAttribute attribute3 = node2.Attributes["type"];
                     XmlAttribute attribute4 = node2.Attributes["name"];
                     Type ijob = Type.GetType(attribute3.Value);
                     if ((ijob != null) && !this.jobList.Contains(attribute4.Value))
                     {
                         Job job = new Job(ijob, node2);
                         if (flag && job.SingleThreaded)
                         {
                             job.InitializeTimer();
                         }
                         else
                         {
                             this.jobList[attribute4.Value] = job;
                         }
                     }
                 }
             }
             if (this.jobList.Count > 0)
             {
                 this.singleTimer = new Timer(new TimerCallback(this.call_back), null, this.Interval, this.Interval);
             }
         }
     }
 }