私は(私のベータ版の)アプリケーションを可能な限り実行し続けようとしています。そのため、重大なエラーが発生してアプリケーションが予期せずシャットダウンした場合に備えて、別のアプリケーションも内部に配置しましtry-catch
た。アプリケーションは、何らかの理由で終了した後でも再開できます。
この特定のシナリオに対してそのような計画を立てるのは正しいですか?
それが正しくない場合、プログラムを実行し続けるために他に何が推奨されますか?Program.cs
catch
Application.Run()
これは、私が何を意味するかを示すサンプルコードです:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Hossein;
using Pishro.Classes;
namespace Pishro
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMain());
}
catch(Exception exc)
{
API.SaveAndShowLog(exc);
Application.Run(new frmMain());
}
}
}
}