public void Start() { MainWindow.This.Dispatcher.Invoke(() => { if (Status == ServerInfoStatus.Stopped) { try { Status = ServerInfoStatus.Started; CurrentServerBase = new ServerProcessInfoBase(); CurrentServerBase.Start("App_" + Name, AssemblyPath); ServerInfoPage.SendToMainHostForHidden(CurrentServerBase.BaseProcess); ProcessStarted?.Invoke(); } catch (Exception ex) { AutoLogger.Default.LogError(ex, "StartServer"); if (CurrentServerBase != null) { CurrentServerBase.Dispose(); CurrentServerBase = null; } Status = ServerInfoStatus.Stopped; } SettingInfo.SaveSettingInfo(); } }); }
public void Stop() { if (Status == ServerInfoStatus.Started) { while (true) { try { CurrentServerBase.Dispose(); CurrentServerBase = null; Status = ServerInfoStatus.Stopped; break; } catch (Exception ex) { AutoLogger.Default.LogError(ex, "Stop Server"); } finally { GC.Collect(); GC.WaitForFullGCComplete(); GC.Collect(); } } } }