1

我想了解如何并行执行一系列功能并能够调试每个..

我正在尝试创建一个控制台应用程序,它将(在编译后)在将通过其任务调度程序执行应用程序的服务器上运行。

    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();

    }
  1. 那是线程/连接函数的方式吗?
  2. 我怎样才能闯入执行的 doFirst() 和 doScond() 代码?
4

1 回答 1

1

您需要等待任务完成,然后通过退出 main 来结束您的应用程序。

尝试类似的东西: -

Task.Factory.StartNew(doFirstOne).ContinueWith(task => doSecondOne()).Wait(); 
于 2012-11-20T20:44:55.803 回答