2017-03-23 56 views
0

我需要做的是这样的:IHttpActionResult超时等待的PowerShell脚本

public IHttpActionResult StartArchiving(string machineName) 
{ 
    //Email users to notice them an archiving started on their machine 
    EmailHelper.SendEmail(some params); 

    //powershell scripting call could extends up to 2-3 hours maybe 
    var answere = PowerShell.Archive(machineName); 

    //Email users to notice them the archiving has stopped on their machine 
    EmailHelper.SendEmail(some params); 
} 

发送第一封电子邮件后,该任务可以持续很长时间。 完成Powershell脚本之后,C#任务仍将继续,并将发送第二封电子邮件,否则任务将停止,并且不会发送电子邮件。

回答

0

听起来好像您需要执行Powershell.Archive()异步调用,这意味着您的代码的其余部分将继续运行,而无需等待Powershell.Archive()完成。我建议阅读关于如何在C#中使用“异步”和“等待”关键字进行异步编程。