C# 退出程序再重新启动

作者: zengde 分类: 笔记 发布时间: 2023-03-18 03:54
/// <summary>
/// 退出登录
/// </summary>
public static void ReLoign()
{
  Application.ExitThread();
  Thread thtmp = new Thread(new ParameterizedThreadStart(Run));
  object appName = Application.ExecutablePath;
  Thread.Sleep(1);
  thtmp.Start(appName);
}

private static void Run(Object appName)
{
  Process ps = new Process
  {
    StartInfo = new ProcessStartInfo
    {
      FileName = appName.ToString()
    }
  };
  ps.Start();
}