private void btnButton_Click(object sender, System.EventArgs e) { if (rbtnPool.IsChecked == true && String.IsNullOrEmpty(txtPool.Text)) { MessageBox.Show("Please specify a pool name"); return; } workitem.JobExecutionEnvironment = new JobExecutionEnvironment(); if (rbtnPool.IsChecked == true) { try { workitem.JobExecutionEnvironment.PoolName = txtPool.Text; (Sender as BatchTreeViewItem).AddWorkItem(workitem); (this.Parent as NavigationWindow).Close(); } catch (Exception ex) { MessageBox.Show(Utils.ExtractExceptionMessage(ex)); } } else { workitem.JobExecutionEnvironment.AutoPoolSpecification = new AutoPoolSpecification(); workitem.JobExecutionEnvironment.AutoPoolSpecification.PoolLifeTimeOption = (rbtnWorkItem.IsChecked == true) ? PoolLifeTimeOption.WorkItem : (rbtnJob.IsChecked == true) ? PoolLifeTimeOption.Job : PoolLifeTimeOption.Invalid; workitem.JobExecutionEnvironment.AutoPoolSpecification.KeepAlive = (rbtnKeepAliveT.IsChecked == true) ? true : false; workitem.JobExecutionEnvironment.AutoPoolSpecification.AutoPoolNamePrefix = txtNamePrefix.Text; CreatePoolP1 p6 = new CreatePoolP1(this.Sender, workitem); NavigationService.Navigate(p6); } }