Exemple #1
0
 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();
         }
     });
 }
Exemple #2
0
 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();
             }
         }
     }
 }