void LoadDocumentAsync(string fileName) { var progress = new ProgressDialog { Title = "Loading file", TaskFunction = (p) => StartLoadFile(fileName, p), }; if (progress.ShowDialog() == DialogResult.OK) { var task = (Task<RuleIndex>)progress.Task; SetupDocument(task.Result); } }
void OnConvert(object sender, EventArgs e) { var progress = new ProgressDialog { Title = "Loading file", TaskFunction = (p) => Task.Factory.StartNew(() => { string newPath = Path.ChangeExtension(this.currentDocument.Name, ".js"); using (FileStream stream = File.Open(newPath, FileMode.Create)) { using (var writer = new StreamWriter(stream)) { Converter.Convert(this.currentDocument, writer, p); } } }) }; progress.ShowDialog(); }
void OnConvertToFiles(object sender, EventArgs e) { var progress = new ProgressDialog { Title = "Converting file", TaskFunction = (p) => Task.Factory.StartNew(() => { string newPath = Path.ChangeExtension(this.currentDocument.Name, ".out"); Converter.ConvertToFiles(this.currentDocument, newPath, p); }) }; progress.ShowDialog(); }