Changeset 246 for trunk/sources
- Timestamp:
- 05/13/08 23:05:09 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Grid/ClientForm.cs
r244 r246 45 45 private ProcessingEngine currentEngine; 46 46 private object connectionLock = new object(); 47 private bool stopped; 47 48 48 49 public ClientForm() { … … 52 53 fetchOperationTimer.Elapsed += new System.Timers.ElapsedEventHandler(fetchOperationTimer_Elapsed); 53 54 statusTextBox.Text = "Stopped"; 55 stopped = true; 54 56 currentGuid = Guid.Empty; 55 57 } … … 62 64 stopButton.Enabled = true; 63 65 statusTextBox.Text = "Waiting for engine"; 66 stopped = false; 64 67 65 68 } catch(CommunicationException ex) { … … 82 85 83 86 private void stopButton_Click(object sender, EventArgs e) { 87 stopped = true; 84 88 fetchOperationTimer.Stop(); 85 89 if(currentEngine != null) 86 90 currentEngine.Abort(); 87 91 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 } 90 96 } 91 97 statusTextBox.Text = "Stopped"; … … 97 103 byte[] engineXml; 98 104 fetchOperationTimer.Stop(); 105 if(stopped) return; 99 106 try { 100 107 bool success; … … 105 112 success = engineStore.TryTakeEngine(out currentGuid, out engineXml); 106 113 } 107 if(success ) {114 if(success && !stopped) { 108 115 currentEngine = RestoreEngine(engineXml); 109 116 if(InvokeRequired) { Invoke((MethodInvoker)delegate() { statusTextBox.Text = "Executing engine"; }); } else statusTextBox.Text = "Executing engine"; … … 122 129 currentEngine.Execute(); 123 130 } 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 } 127 136 } 128 137 } catch(TimeoutException timeoutException) {
Note: See TracChangeset
for help on using the changeset viewer.