Exemple #1
0
 private void Backup(MainForm _main_form_control)
 {
     List<TaskInfo> tasks_info = DiffLinkAndPreTask();
     // ProgressBar.Maximum = tasks.Count;
     if (tasks_info.Count != 0)
     {
         _main_form_control.Invoke(max_delegate, tasks_info.Count);
         for (int i = 0; i < tasks_info.Count; i++)
         {
             try
             {
                 TaskInfo info = tasks_info[i];
                 //task_set[i].ContinueWith((task) => TaskEndedFault(this, info.link_url, info.title), TaskContinuationOptions.OnlyOnFaulted);
                 task_set[i].ContinueWith((task) => TaskEnded(this, info.user, info.xml_doc, info.title, info.link_url), TaskContinuationOptions.NotOnFaulted);
                 task_set[i].RunSynchronously();
                 task_set[i].Wait();
             }
             catch (AggregateException e)
             {
                 // if faulted,then do the false one's continue task.
                 this.Invoke(this.my_delegate, new object[] { tasks_info[i].link_url, tasks_info[i].title, false });
             }
             catch (Exception e)
             {
                 Console.WriteLine(e.ToString());
             }
         }
     }
     else
     {
         MessageBox.Show("没有新的博客需要备份!");
     }
 }
Exemple #2
0
 /// <summary>
 /// Converts a PdfDocument object from HTML to PDF using default environment settings.
 /// </summary>
 /// <param name="document">The PDF input document.</param>
 /// <param name="output">An object holding the output settings.</param>
 public static Task ConvertHtmlToPdfAsync(PdfDocument document, PdfOutput output, MainForm _main_control)
 {
     Task temp = new Task(() => ConvertHtmlToPdf(document, null, output));
     return temp;
 }
Exemple #3
0
 private void TaskEnded(MainForm _main_form_control, XmlNode _user, XmlDocument _xml_doc, string _title, string _link_url)
 {
     _user.AppendChild(GetLinkNode(_xml_doc, _title, _link_url));
     //Update progress and log's text
     _main_form_control.Invoke(_main_form_control.my_delegate, new object[] { _link_url, _title, true });
 }