예제 #1
0
        public async Task Scan(string url, string[] DictFiles)
        {
            this.url          = url;
            this.nTasks       = config.getTasks();
            this.nHttpTimeout = config.getHttpTimeout();
            // 计算总行数
            TotalLines = 0;
            foreach (string filename in DictFiles)
            {
                TotalLines += await GetFileLines(filename);
            }
            // 开始扫描
            CurLine = 0;
            List <Task> lstTasks = new List <Task>();

            foreach (string filename in DictFiles)
            {
                if (!File.Exists(filename))
                {
                    continue;
                }
                var task = Task.Run(() => DoScan(filename));
                lstTasks.Add(task);
            }
            await Task.WhenAll(lstTasks);

            /*
             * if (OnFinished != null)
             * {
             *  OnFinished(this, new EventArgs());
             * }*/
            var t = Task.Run(() => CheckStop());
            await Task.WhenAll(t);
        }
예제 #2
0
 private void FormConfig_Load(object sender, EventArgs e)
 {
     config = new CConfig();
     nudHttpTimeout.Value = (decimal)config.getHttpTimeout();
     nudTasks.Value       = (decimal)config.getTasks();
 }