void RefreshInstanceDataAsync() { //stop watcher data retreival if (watcherTimer != null) { watcherTimer.Stop(); } //begin retreival of instances var ec2worker = new AWSInstanceRetreiver() { AWSAccessKey = Settings.Default.AWSAccessKey, AWSSecretKey = Settings.Default.AWSSecretKey, EC2Region = Region.EU }; ec2worker.Completed += (sender, e) => { Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => { UpdateInstanceDataUI(e.Result); //fetch data on a timer RefreshInstanceMonitorDataAsync(); } )); }; ec2worker.FetchAsync(); }
public RunCloudCommandDialog() { AllocConsole(); InitializeComponent(); ViewModel = new RunCloudCommandViewModel(); ViewModel.ServerGroups = new ObservableCollection <CheckedTreeGroup>(); /*ViewModel.Servers.Add(new CheckedListItem("badger")); * ViewModel.Servers.Add(new CheckedListItem("wsdf")); * ViewModel.Servers.Add(new CheckedListItem("sdafds"));*/ this.DataContext = ViewModel; //begin retreival of instances var ec2worker = new AWSInstanceRetreiver() { AWSAccessKey = Settings.Default.AWSAccessKey, AWSSecretKey = Settings.Default.AWSSecretKey, EC2Region = Region.EU }; var lbWorker = new AWSLoadBalancerServersRetreiver() { AWSAccessKey = Settings.Default.AWSAccessKey, AWSSecretKey = Settings.Default.AWSSecretKey, EC2Region = Region.EU }; ec2worker.Completed += (sender, e) => { Dispatcher.BeginInvoke((Action)(() => { _Connections = e.Result; UpdateTreeView(); } )); }; lbWorker.Completed += (sender, e) => { Dispatcher.BeginInvoke((Action)(() => { _LoadBalancerGroupings = e.Result; UpdateTreeView(); })); }; ec2worker.FetchAsync(); lbWorker.FetchAsync(); }