Free cookie consent management tool by TermsFeed Policy Generator

Changeset 246


Ignore:
Timestamp:
05/13/08 23:05:09 (17 years ago)
Author:
gkronber
Message:

minor bugfixes (related to #149)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Grid/ClientForm.cs

    r244 r246  
    4545    private ProcessingEngine currentEngine;
    4646    private object connectionLock = new object();
     47    private bool stopped;
    4748
    4849    public ClientForm() {
     
    5253      fetchOperationTimer.Elapsed += new System.Timers.ElapsedEventHandler(fetchOperationTimer_Elapsed);
    5354      statusTextBox.Text = "Stopped";
     55      stopped = true;
    5456      currentGuid = Guid.Empty;
    5557    }
     
    6264        stopButton.Enabled = true;
    6365        statusTextBox.Text = "Waiting for engine";
     66        stopped = false;
    6467
    6568      } catch(CommunicationException ex) {
     
    8285
    8386    private void stopButton_Click(object sender, EventArgs e) {
     87      stopped = true;
    8488      fetchOperationTimer.Stop();
    8589      if(currentEngine != null)
    8690        currentEngine.Abort();
    8791      lock(connectionLock) {
    88         IAsyncResult closeResult = factory.BeginClose(null, null);
    89         factory.EndClose(closeResult);
     92        if(factory.State == CommunicationState.Opened || factory.State == CommunicationState.Opening) {
     93          IAsyncResult closeResult = factory.BeginClose(null, null);
     94          factory.EndClose(closeResult);
     95        }
    9096      }
    9197      statusTextBox.Text = "Stopped";
     
    97103      byte[] engineXml;
    98104      fetchOperationTimer.Stop();
     105      if(stopped) return;
    99106      try {
    100107        bool success;
     
    105112          success = engineStore.TryTakeEngine(out currentGuid, out engineXml);
    106113        }
    107         if(success) {
     114        if(success && !stopped) {
    108115          currentEngine = RestoreEngine(engineXml);
    109116          if(InvokeRequired) { Invoke((MethodInvoker)delegate() { statusTextBox.Text = "Executing engine"; }); } else statusTextBox.Text = "Executing engine";
     
    122129          currentEngine.Execute();
    123130        } else {
    124           if(InvokeRequired) { Invoke((MethodInvoker)delegate() { statusTextBox.Text = "Waiting for engine"; }); } else statusTextBox.Text = "Waiting for engine";
    125           fetchOperationTimer.Interval = 5000;
    126           fetchOperationTimer.Start();
     131          if(!stopped) {
     132            if(InvokeRequired) { Invoke((MethodInvoker)delegate() { statusTextBox.Text = "Waiting for engine"; }); } else statusTextBox.Text = "Waiting for engine";
     133            fetchOperationTimer.Interval = 5000;
     134            fetchOperationTimer.Start();
     135          }
    127136        }
    128137      } catch(TimeoutException timeoutException) {
Note: See TracChangeset for help on using the changeset viewer.