Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7135


Ignore:
Timestamp:
12/06/11 14:30:47 (13 years ago)
Author:
ascheibe
Message:

#1672 some fixes for the slave tray ui:

  • removed some more magic numbers
  • fixed reconnecting to windows service when it was stopped
  • added more time for stopping/starting windows service so that no exception is thrown because of a timeout
Location:
trunk/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/Properties/Settings.Designer.cs

    r7132 r7135  
    7171            }
    7272        }
     73       
     74        [global::System.Configuration.UserScopedSettingAttribute()]
     75        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     76        [global::System.Configuration.DefaultSettingValueAttribute("00:00:20")]
     77        public global::System.TimeSpan ServiceStartStopTimeout {
     78            get {
     79                return ((global::System.TimeSpan)(this["ServiceStartStopTimeout"]));
     80            }
     81            set {
     82                this["ServiceStartStopTimeout"] = value;
     83            }
     84        }
     85       
     86        [global::System.Configuration.UserScopedSettingAttribute()]
     87        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     88        [global::System.Configuration.DefaultSettingValueAttribute("00:00:03")]
     89        public global::System.TimeSpan ServiceReconnectTimeout {
     90            get {
     91                return ((global::System.TimeSpan)(this["ServiceReconnectTimeout"]));
     92            }
     93            set {
     94                this["ServiceReconnectTimeout"] = value;
     95            }
     96        }
    7397    }
    7498}
  • trunk/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/Properties/Settings.settings

    r7132 r7135  
    1515      <Value Profile="(Default)">HeuristicLab.Clients.Hive.Slave</Value>
    1616    </Setting>
     17    <Setting Name="ServiceStartStopTimeout" Type="System.TimeSpan" Scope="User">
     18      <Value Profile="(Default)">00:00:20</Value>
     19    </Setting>
     20    <Setting Name="ServiceReconnectTimeout" Type="System.TimeSpan" Scope="User">
     21      <Value Profile="(Default)">00:00:03</Value>
     22    </Setting>
    1723  </Settings>
    1824</SettingsFile>
  • trunk/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/SlaveCmdsWithKill.cs

    r6983 r7135  
    126126
    127127    private void StartService() {
    128       TimeSpan timeout = TimeSpan.FromMilliseconds(5000);
    129 
    130128      ServiceController service = new ServiceController(serviceName);
    131129      try {
    132130        if (service.Status == ServiceControllerStatus.Running) {
    133131          service.Stop();
    134           service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
     132          service.WaitForStatus(ServiceControllerStatus.Stopped, Settings.Default.ServiceStartStopTimeout);
    135133        }
    136134
    137135        service.Start();
    138         service.WaitForStatus(ServiceControllerStatus.Running, timeout);
     136        service.WaitForStatus(ServiceControllerStatus.Running, Settings.Default.ServiceStartStopTimeout);
    139137      }
    140138      catch (InvalidOperationException ex) {
     
    147145
    148146    private void StopService() {
    149       TimeSpan timeout = TimeSpan.FromMilliseconds(7000);
    150 
    151147      ServiceController service = new ServiceController(serviceName);
    152148      try {
    153149        if (service.Status == ServiceControllerStatus.Running) {
    154150          service.Stop();
    155           service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
     151          service.WaitForStatus(ServiceControllerStatus.Stopped, Settings.Default.ServiceStartStopTimeout);
    156152        }
    157153      }
    158154      catch (InvalidOperationException ex) {
    159         MessageBox.Show("Error starting service: Hive Slave Service not found!" + Environment.NewLine + ex.ToString());
     155        MessageBox.Show("Error stopping service: Hive Slave Service not found!" + Environment.NewLine + ex.ToString());
    160156      }
    161157      catch (Exception ex) {
    162         MessageBox.Show("Error starting service, exception is: " + Environment.NewLine + ex.ToString());
     158        MessageBox.Show("Error stopping service, exception is: " + Environment.NewLine + ex.ToString());
    163159      }
    164160    }
  • trunk/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/SlaveItem.cs

    r6983 r7135  
    9191    public bool ReconnectToSlaveCore() {
    9292      try {
     93        DeregisterEvents();
    9394        pipeProxy = pipeFactory.CreateChannel();
    9495        StatusCommons st = pipeProxy.Subscribe();
    9596        if (st != null) {
     97          RegisterEvents();
    9698          OnStatusChanged(st);
    9799          return true;
  • trunk/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/SlaveMainViewBase.cs

    r6983 r7135  
    6262    protected override void DeregisterContentEvents() {
    6363      Content.CoreConnectionChanged -= new EventHandler<Common.EventArgs<CoreConnection>>(Content_CoreConnectionChanged);
     64      Content.SlaveDisplayStateChanged -= new EventHandler<Common.EventArgs<SlaveDisplayStat>>(Content_SlaveDisplayStateChanged);
    6465      base.DeregisterContentEvents();
    6566    }
     
    6869      base.RegisterContentEvents();
    6970      Content.CoreConnectionChanged += new EventHandler<Common.EventArgs<CoreConnection>>(Content_CoreConnectionChanged);
     71      Content.SlaveDisplayStateChanged += new EventHandler<Common.EventArgs<SlaveDisplayStat>>(Content_SlaveDisplayStateChanged);
     72    }
     73
     74    void Content_SlaveDisplayStateChanged(object sender, Common.EventArgs<SlaveDisplayStat> e) {
     75      if (e.Value == SlaveDisplayStat.NoService) {
     76        Task.Factory.StartNew(Connector);
     77      }
    7078    }
    7179
    7280    void Content_CoreConnectionChanged(object sender, Common.EventArgs<CoreConnection> e) {
    7381      if (e.Value == CoreConnection.Offline) {
    74         Connector();
     82        Task.Factory.StartNew(Connector);
    7583      }
    7684    }
     
    119127
    120128        if (!connected) {
    121           Thread.Sleep(1000);
     129          Thread.Sleep(Settings.Default.ServiceReconnectTimeout);
    122130        }
    123131      }
  • trunk/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/app.config

    r7132 r7135  
    2020                <value>HeuristicLab.Clients.Hive.Slave</value>
    2121            </setting>
     22            <setting name="ServiceStartStopTimeout" serializeAs="String">
     23                <value>00:00:20</value>
     24            </setting>
     25            <setting name="ServiceReconnectTimeout" serializeAs="String">
     26                <value>00:00:03</value>
     27            </setting>
    2228        </HeuristicLab.Clients.Hive.SlaveCore.Views.Properties.Settings>
    2329    </userSettings>
Note: See TracChangeset for help on using the changeset viewer.