()=> {; .Net任务中的错误

时间:2018-05-02 06:21:42

标签: c# lambda task

我开始玩.Net任务,我收到此错误()=>{ ; expected并且不知道原因:

修改

这是我的代码:

private void create_alias_button_Click(object sender , RoutedEventArgs e)
{           
   System.Threading.Tasks.Task t = System.Threading.Tasks.Task.Run(() => { addAliasDomains()});
    t.Wait();
}

private void addAliasDomains()
{
    string pathToAddAliasScript = ConfigurationManager.AppSettings["pathToAddAliasScript"];
    Runspace runspace = RunspaceFactory.CreateRunspace();
    runspace.Open();
    using (PowerShell powershell = PowerShell.Create())
    {
        foreach (string s in domains_listBox.Items)
        {
            PSCommand command = new PSCommand();
            powershell.AddCommand(_pathToSourcesFolder + "\\" + pathToAddAliasScript);
            powershell.AddParameter("alias" , s);
            powershell.Runspace = runspace;
            Collection<PSObject> results = powershell.Invoke();
        }
    }
}

0 个答案:

没有答案