Last change
on this file since 12823 was
12823,
checked in by ascheibe, 9 years ago
|
#2017 added a new mode to hive drain for extracting runs and storing them in a single file
|
File size:
1.5 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Threading.Tasks;
|
---|
3 | using System.Windows.Forms;
|
---|
4 | using HeuristicLab.Common;
|
---|
5 | using HeuristicLab.Core;
|
---|
6 |
|
---|
7 | namespace HeuristicLab.HiveDrain {
|
---|
8 | public partial class HiveDrainMainWindow : Form {
|
---|
9 | public HiveDrainMainWindow() {
|
---|
10 | InitializeComponent();
|
---|
11 | ContentManager.Initialize(new PersistenceContentManager());
|
---|
12 | }
|
---|
13 |
|
---|
14 | private Task task;
|
---|
15 |
|
---|
16 | public static ThreadSafeLog Log = new ThreadSafeLog();
|
---|
17 |
|
---|
18 | private void EnableButton() {
|
---|
19 | if (InvokeRequired)
|
---|
20 | Invoke(new Action(EnableButton));
|
---|
21 | else
|
---|
22 | downloadButton.Enabled = true;
|
---|
23 | }
|
---|
24 |
|
---|
25 | private void downloadButton_Click(object sender, EventArgs e) {
|
---|
26 | string pattern = (patterTextBox.Text.Trim().Length > 0) ? patterTextBox.Text.Trim() : null;
|
---|
27 | Log.Clear();
|
---|
28 | logView.Content = Log;
|
---|
29 | downloadButton.Enabled = false;
|
---|
30 |
|
---|
31 | JobDownloader jobDownloader = new JobDownloader(Environment.CurrentDirectory, pattern, Log, oneFileCheckBox.Checked);
|
---|
32 | task = new Task(jobDownloader.Start);
|
---|
33 | task.ContinueWith(x => { Log.LogMessage("All tasks written, quitting."); EnableButton(); }, TaskContinuationOptions.OnlyOnRanToCompletion);
|
---|
34 | task.ContinueWith(x => { Log.LogMessage("Unexpected Exception while draining the Hive: " + x.Exception.ToString()); EnableButton(); }, TaskContinuationOptions.OnlyOnFaulted);
|
---|
35 | task.Start();
|
---|
36 | }
|
---|
37 |
|
---|
38 | private void HiveDrainMainWindow_FormClosing(object sender, FormClosingEventArgs e) {
|
---|
39 | //TODO: implement task cancelation
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.