private void btnStopCollection_Click(object sender, RoutedEventArgs e) { //ColorAnimation myColorAnimation = new ColorAnimation(); //myColorAnimation.From = Colors.White; //myColorAnimation.To = Colors.Green; //myColorAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(1000)); //myColorAnimation.RepeatBehavior = RepeatBehavior.Forever; //Storyboard myStoryboard = new Storyboard(); //myStoryboard.Children.Add(myColorAnimation); //Storyboard.SetTargetName(myColorAnimation, "Button1"); //Storyboard.SetTargetProperty(myColorAnimation, new PropertyPath("Background.Color")); //myStoryboard.Begin(this); //myStoryboard.Stop(this); UpdateActionStarted(); if (this.collectionMode == CollectionMode.Web) { BaseDataCollector collector = new IISDataCollector(this.collectionPlanNameAndPath, this.txtOutputLocation.Text.Trim().ToString(), (string)this.cbAppPools.SelectedValue); Task <ICommandStatus> task = Task <ICommandStatus> .Factory.StartNew(() => collector.StopCollection()); task.ContinueWith((antecendent) => { UpdateActionCompleted((CommandStatus)task.Result); }, TaskScheduler.FromCurrentSynchronizationContext()); } else if (this.collectionMode == CollectionMode.Service) { BaseDataCollector collector = new WindowsServiceDataCollector(this.collectionPlanNameAndPath, this.txtOutputLocation.Text.Trim().ToString(), this.cbService.SelectedItem.ToString()); Task <ICommandStatus> task = Task <ICommandStatus> .Factory.StartNew(() => collector.StopCollection()); task.ContinueWith((antecendent) => { UpdateActionCompleted((WindowsServiceCollectionCommandStatus)task.Result); }, TaskScheduler.FromCurrentSynchronizationContext()); } else { BaseDataCollector collector = new ProcessDataCollector(this.processIds, this.collectionPlanNameAndPath, this.txtOutputLocation.Text.Trim().ToString()); Task <ICommandStatus> task = Task <ICommandStatus> .Factory.StartNew(() => collector.StopCollection()); task.ContinueWith((antecendent) => { UpdateActionCompleted((ProcessCollectionCommandStatus)task.Result); }, TaskScheduler.FromCurrentSynchronizationContext()); } }
private void btnStartCollection_Click(object sender, RoutedEventArgs e) { if (!Validate()) { return; } UpdateActionStarted(); if (this.collectionMode == CollectionMode.Web) { BaseDataCollector collector = new IISDataCollector(this.collectionPlanNameAndPath, this.txtOutputLocation.Text.Trim().ToString(), (string)this.cbAppPools.SelectedValue); Task <ICommandStatus> task = Task <ICommandStatus> .Factory.StartNew(() => collector.StartCollection()); task.ContinueWith((antecendent) => { UpdateActionCompleted((CommandStatus)task.Result); }, TaskScheduler.FromCurrentSynchronizationContext()); } else if (this.collectionMode == CollectionMode.Service) { BaseDataCollector collector = new WindowsServiceDataCollector(this.collectionPlanNameAndPath, this.txtOutputLocation.Text.Trim().ToString(), this.cbService.SelectedItem.ToString()); Task <ICommandStatus> task = Task <ICommandStatus> .Factory.StartNew(() => collector.StartCollection()); task.ContinueWith((antecendent) => { UpdateActionCompleted((WindowsServiceCollectionCommandStatus)task.Result); }, TaskScheduler.FromCurrentSynchronizationContext()); } else { BaseDataCollector collector = new ProcessDataCollector(this.collectionPlanNameAndPath, this.txtOutputLocation.Text.Trim().ToString(), Path.GetFileName(this.txtExecutablePath.Text.Trim()), this.txtExecutablePath.Text.Trim(), this.txtCommandLine.Text.Trim()); Task <ICommandStatus> task = Task <ICommandStatus> .Factory.StartNew(() => collector.StartCollection()); task.ContinueWith((antecendent) => { UpdateActionCompleted((ProcessCollectionCommandStatus)task.Result); }, TaskScheduler.FromCurrentSynchronizationContext()); } }