- Timestamp:
- 11/23/09 11:29:26 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Grid/3.2/ClientForm.cs
r2518 r2523 46 46 InitializeComponent(); 47 47 clientControllers = new List<ClientController>(); 48 nClientsControl.Value = Environment.ProcessorCount; 49 clientControllerBindingSource.DataSource = clientControllers; 50 UpdateControl(); 48 lock (clientControllers) { 49 nClientsControl.Value = Environment.ProcessorCount; 50 clientControllerBindingSource.DataSource = clientControllers; 51 UpdateControl(); 52 } 51 53 } 52 54 53 55 private void startButton_Click(object sender, EventArgs e) { 54 foreach (var client in clientControllers) { 55 client.Client.Start(addressTextBox.Text); 56 lock (clientControllers) { 57 foreach (var client in clientControllers) { 58 client.Client.Start(addressTextBox.Text); 59 } 60 UpdateControl(); 56 61 } 57 UpdateControl();58 62 } 59 63 60 64 private void stopButton_Click(object sender, EventArgs e) { 61 foreach (var client in clientControllers) { 62 client.Client.Stop(); 65 lock (clientControllers) { 66 foreach (var client in clientControllers) { 67 client.Client.Stop(); 68 } 69 UpdateControl(); 63 70 } 64 UpdateControl();65 71 } 66 72 67 73 private void UpdateControl() { 68 foreach (var client in clientControllers) { 69 if (client.Client.Waiting) { 70 startButton.Enabled = false; 71 stopButton.Enabled = true; 72 client.Status = "Waiting for engine"; 73 } else if (client.Client.Executing) { 74 startButton.Enabled = false; 75 stopButton.Enabled = true; 76 client.Status = "Executing engine"; 77 } else if (client.Client.Stopped) { 78 startButton.Enabled = true; 79 stopButton.Enabled = false; 80 client.Status = "Stopped"; 74 lock (clientControllers) { 75 foreach (var client in clientControllers) { 76 if (client.Client.Waiting) { 77 startButton.Enabled = false; 78 stopButton.Enabled = true; 79 client.Status = "Waiting for engine"; 80 } else if (client.Client.Executing) { 81 startButton.Enabled = false; 82 stopButton.Enabled = true; 83 client.Status = "Executing engine"; 84 } else if (client.Client.Stopped) { 85 startButton.Enabled = true; 86 stopButton.Enabled = false; 87 client.Status = "Stopped"; 88 } 89 client.Message = client.Client.StatusMessage; 81 90 } 82 client .Message = client.Client.StatusMessage;91 clientControllerBindingSource.ResetBindings(false); 83 92 } 84 clientGrid.Invalidate();85 93 } 86 94 … … 90 98 91 99 private void nClientsControl_ValueChanged(object sender, EventArgs e) { 92 if (nClientsControl.Value < 0) 93 nClientsControl.Value = 0; 94 while (clientControllers.Count < nClientsControl.Value) 95 clientControllers.Add(new ClientController() { Client = new GridClient() }); 96 while (clientControllers.Count > nClientsControl.Value) { 97 try { 98 clientControllers[clientControllers.Count - 1].Client.Stop(); 99 clientControllers.RemoveAt(clientControllers.Count - 1); 100 } catch { } 100 lock (clientControllers) { 101 if (nClientsControl.Value < 0) 102 nClientsControl.Value = 0; 103 while (clientControllers.Count < nClientsControl.Value) { 104 clientControllers.Add(new ClientController() { Client = new GridClient() }); 105 } 106 while (clientControllerBindingSource.Count > nClientsControl.Value) { 107 GridClient client = clientControllers.Last().Client; 108 if (!client.Stopped) 109 client.Stop(); 110 clientControllers.RemoveAt(clientControllerBindingSource.Count - 1); 111 } 101 112 } 102 client Grid.Invalidate();113 clientControllerBindingSource.ResetBindings(false); 103 114 } 104 115 }
Note: See TracChangeset
for help on using the changeset viewer.