@nick_gabpe 덕분에 문제를 피할 수있었습니다.
public static void RebootMachine()
{
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (o, ea) =>
{
System.Threading.Thread.Sleep(15000);
};
worker.RunWorkerCompleted += (o, ea) =>
{
System.Diagnostics.Process.Start("shutdown.exe", "-f -r -t 0");
};
worker.RunWorkerAsync();
DialogResult result = MsgBox.Show("The device will be initialized in 15 seconds",
"Restarting device", MsgBox.Buttons.RestartNow, MsgBox.Icon.Info, MsgBox.AnimateStyle.FadeIn);
if (result == DialogResult.Yes)
{
System.Diagnostics.Process.Start("shutdown.exe", "-f -r -t 0");
}
}
사용'윈도우 API : 그것은 산뜻한 대답,하지만 작동하는지
나는 "다시는 지금"버튼을, 나는 내 문제에 대한 BackgroundWorker에 사용을 가진 메시지 박스가 ..확실하지 않음 '전화 [관련 게시물] (http://stackoverflow.com/questions/102567/how-to-shut-down-the-computer-from-c-sharp)에 설명되어 있습니다. –