我开始玩.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();
}
}
}