我有 ac# 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 秒后启动。
谢谢!
这可能吗?