gpt4 book ai didi

c# - 如何在出错时重新启动嵌入式 NETMF C# 程序?

转载 作者:太空狗 更新时间:2023-10-30 00:31:46 25 4
gpt4 key购买 nike

<分区>

我有一个小型的、长时间运行的、嵌入式的 NETMF 程序,它由于未知原因而停止(参见 How do we trouble shoot a long-running NETMF program that stops in production?)。作为一种解决方法,我希望它在失败时自动重启。我的感觉是 try-catch block 可以做到这一点。如何?这可能吗?有更好的方法吗?

public class Program
{
private static Timer timer;
public static void Main()
{
Program p = new Program();

Program.timer =
new Timer(this.TimerCallback_DoSomething, new object(), 0, 1000);

Thread.Sleep(Timeout.Infinite);
}

private void TimerCallback_DoSomething(object stateInfo)
{
// do something
}
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com