我有一個運行後檢查的安裝。什麼我希望做的是調出功能運行函數直到成功
private void ApacheTest()
{
if(!File.Exists(HTTPD_PATH))
{
amountdl.Text = "Apache Not Found! Installation Corrupt!";
}
else
{
StartApacheServer();
}
if(ApacheRunning() == false)
{
amountdl.Text = "Apache Is Starting";
}
else
{
amountdl.Text = "Apache Started";
}
}
我希望它繼續運行這個功能我希望發生的是,直到ApacheRunning() == true
。這在C#中可能嗎?
'ServiceController'有一個內置的['WaitForStatus'](https://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.waitforstatus(V = vs.110)。 aspx)如果你想啓動Apache服務。 –
謝謝!我剛纔所做的是在'if(ApacheRunning()== false){ApacheTest(); }'但我有一種感覺'WaitForStatus'可能是運行這個的首選方式。 –