我将了解如何并行执行一系列函数并能够调试每个函数。
我正在尝试创建一个控制台应用程序(在编译之后), 在将通过其任务调度程序执行应用程序的服务器上运行。
static void Main(string[] args)
{
Task.Factory.StartNew(
// first b. point here (will not "step into")
() =>
doFirstOne().ContinueWith(task => doSecondOne())
);
}
public static IWebDriver AllDayWbDrvr;
static string extrctdStr = "";
public static void doFirstOne()
{
// <<<<<<<----- brakePoint here nothing steps in
SeparatedClass.IeEnginGenerator IeNgn = new SeparatedClass.IeEnginGenerator();
AllDayWbDrvr = IeNgn.ExtractPageContent(firstUrl....);
var a = AllDayWbDrvr.FindElements(By.Id("anyID"));
IWebElement IwbElm = IWebDrvRdonlyColl.ElementAt(1).FindElements(By.TagName("td"))[0];
extrctedStr = IwbElm.Text;
// plan is to append extracted text to one shared file that will log all results
string fNm = @"C:\Inetpub\wwwroot\dolarRate.asp";
File.WriteAllText(fNm, extrctdStr);
AllDWbDrvr.Close();
IeNgn.service.Dispose();
}
public static void doSecondOne()
{
SeparatedClass.IeEnginGenerator IeNgn = new SeparatedClass.IeEnginGenerator();
AllDayWbDrvr = IeNgn.ExtractPageContent("secondURL....");
var a = AllDayWbDrvr.FindElements(By.ClassName("WpBody"));
IWebElement IwbElm = IeNgn.IWebDrvRdonlyColl.ElementAt(5).FindElements(By.TagName("td"))[1];
extrctedStr = IwbElm.Text;
string fNm = @"C:\Inetpub\wwwroot\anyOtherFile.asp";
File.WriteAllText(fNm, extrctdStr);
AllDWbDrvr.Close();
IeNgn.service.Dispose();
}
答案 0 :(得分:1)
您需要等待任务完成,然后退出main。
结束您的应用程序尝试类似: -
Task.Factory.StartNew(doFirstOne).ContinueWith(task => doSecondOne()).Wait();