public static void DOTaskWithAsync(MyLittleClock t) { Console.WriteLine(" Task really Start!"); //string _html = LocalTaskImporter(); for (int i = startPage; i < endPage; i++) { string downloadpage = websiteLink + "thread0806.php?fid=25&search=&page=" + i.ToString(); FirstLayerAnalyzer(T66YWebDownloader(downloadpage), downloadpage); } for (int i = 0; i < secondPageLinks.Count; i++) { secondPageHtml.Add(T66YWebDownloader(secondPageLinks[i])); } for (int i = 0; i < secondPageHtml.Count; i++) { SecondLayerAnalyzer(secondPageHtml[i]); } t.CheckPointHandler += TaskPoolReview; /* * await Task.Run(() => { * MyTask slowTask = new MyTask(5000, 10, t); * List<MyTask> taskPool = t.userData as List<MyTask>; * if (taskPool != null) * taskPool.Add(slowTask); * slowTask.DoTask(); * }, t.ct); */ }
public MyTask(string _typeOfTask, int _taskLivingSpan, string _filePath, string _directoryPath, Uri _downloadlink, string _referLink, MyLittleClock t) { typeOfTask = _typeOfTask; taskLivingSpan = new TimeSpan(0, 0, _taskLivingSpan); Ticker = t; taskCt = taskCts.Token; //taskCt.Register(); savingFilePath = _filePath; savingDirectory = _directoryPath; downloadLink = _downloadlink; referLink = _referLink; retryTimes = 0; taskComplete = false; }