Changeset 219 for trunk/sources/HeuristicLab.Grid/ClientForm.cs
- Timestamp:
- 05/06/08 12:22:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Grid/ClientForm.cs
r115 r219 46 46 private ProcessingEngine currentEngine; 47 47 private string clientUrl; 48 private object locker = new object();49 48 50 49 public ClientForm() { … … 62 61 63 62 // windows XP returns the external ip on index 0 while windows vista returns the external ip on index 2 64 if 65 clientUrl = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[2] + ":" + clientPort.Text + "/Grid/Client";63 if(System.Environment.OSVersion.Version.Major >= 6) { 64 clientUrl = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[2] + ":" + clientPort.Text + "/Grid/Client"; 66 65 } else { 67 clientUrl = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[0] + ":" + clientPort.Text + "/Grid/Client";66 clientUrl = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[0] + ":" + clientPort.Text + "/Grid/Client"; 68 67 } 69 68 … … 87 86 statusTextBox.Text = "Waiting for engine"; 88 87 89 } catch 88 } catch(CommunicationException ex) { 90 89 MessageBox.Show("Exception while connecting to the server: " + ex.Message); 91 90 clientHost.Abort(); … … 106 105 107 106 private void fetchOperationTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { 108 lock(locker) {109 byte[] engineXml;110 fetchOperationTimer.Stop();111 if(engineStore.TryTakeEngine( clientUrl,out currentGuid, out engineXml)) {107 byte[] engineXml; 108 fetchOperationTimer.Stop(); 109 try { 110 if(engineStore.TryTakeEngine(out currentGuid, out engineXml)) { 112 111 currentEngine = RestoreEngine(engineXml); 113 112 if(InvokeRequired) { Invoke((MethodInvoker)delegate() { statusTextBox.Text = "Executing engine"; }); } else statusTextBox.Text = "Executing engine"; … … 126 125 fetchOperationTimer.Start(); 127 126 } 127 } catch(Exception ex) { 128 currentEngine = null; 129 currentGuid = Guid.Empty; 130 fetchOperationTimer.Interval = 5000; 131 fetchOperationTimer.Start(); 128 132 } 129 133 } 130 134 public void Abort(Guid guid) { 131 lock(locker) { 132 if(!IsRunningEngine(guid)) return; 133 currentEngine.Abort(); 134 } 135 throw new NotSupportedException(); 135 136 } 136 137 public bool IsRunningEngine(Guid guid) { 137 return currentGuid == guid;138 throw new NotSupportedException(); 138 139 } 139 140 private ProcessingEngine RestoreEngine(byte[] engine) {
Note: See TracChangeset
for help on using the changeset viewer.