我有一个 c# wpf 应用程序,在 main() 方法中,我检查某个条件,如果为真,我运行另一个进程,但是,我需要在某个超时后启动该进程。所以,例如:
override OnStartUp()
{
if(condition == true)
{
ProcessStartInfo p = new ProcessStartInfo("filePath");
p.Start(); // This should wait for like say 5 seconds and then start.
return; // This will exit the current program.
}
}
我可以使用 Thread.Sleep() 但这会导致当前程序也进入休眠状态。 因此,换句话说,我希望当前程序立即终止,然后在 5 秒后启动新进程。
谢谢!
这可能吗?
最佳答案
如果第一个进程创建第三个程序怎么办。第一个程序会立即退出,而第三个程序只会休眠 5 秒钟,然后启动第二个程序。
关于c# - 在 C# 中的某个时间间隔后启动进程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12607687/