示例#1
0
        private void UpdateWorkersInRegion(IEnumerable <AwsRegionLocations> regions)
        {
            if (updateWorkersInputBox.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    foreach (var region in regions)
                    {
                        var updateFile = string.Format("deployments/{0}", updateWorkersInputBox.Input);
                        foreach (var instance in controlRegionDictionary[region].RegionDetails.Instances)
                        {
                            var result = workerCaller.UpdateWorker(instance, updateFile);

                            InstancesInRegionListView.UIThread(() =>
                            {
                                InstancesInRegionListView.UpdateListViewRow(instance.InstanceId, row =>
                                {
                                    row.SubItems[3].Text = result ? "Update attempted" : "Update failed";
                                });
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("There was an error: " + ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#2
0
        private void RefreshWorkers(AwsRegionLocations region)
        {
            // Use canRefreshWorkers to ensure that we don't try to refresh workers while a refresh is in progress
            if (canRefreshWorkers)
            {
                canRefreshWorkers = false;

                var regionControl = controlRegionDictionary[region];
                var instances     = regionControl.RegionDetails.Instances;

                // Go into the UI thread to clear out the current listview and re-add all the instances to it
                InstancesInRegionListView.UIThread(() =>
                {
                    InstancesInRegionListView.Items.Clear();
                    foreach (var instance in instances)
                    {
                        instance.WorkerInfo = null;
                        InstancesInRegionListView.Items.Add(instance.ToListViewItem());
                    }
                });

                var updateInstanceTasks = instances.Select(RefreshWorker);

                Task.WhenAll(updateInstanceTasks.ToArray())
                .ContinueWith(t =>
                {
                    // Once we're all done refreshing all of the workers allow the refresh to happen again
                    canRefreshWorkers = true;
                });
            }
        }
示例#3
0
        private Task RefreshWorker(InstanceInfo instance)
        {
            return(Task.Factory.StartNew(() =>
            {
                workerCaller.RefreshWorkerInfo(instance);

                InstancesInRegionListView.UIThread(() =>
                {
                    InstancesInRegionListView.UpdateListViewRow(instance.InstanceId, row =>
                    {
                        row.UpdateListViewItem(instance.WorkerInfo);
                    });
                });
            }));
        }