Ejemplo n.º 1
0
        private void CreateSingleDumperThread(WzFile file, WzXml wzxml, string fileName)
        {
            IsFinished = false;
            var startTime = DateTime.Now;
            var mainTask  = Task.Factory.StartNew(() => DirectoryDumperThread(file, wzxml, true));

            mainTask.ContinueWith(p => {
                var duration   = DateTime.Now - startTime;
                string message = String.Empty;
                if (CancelSource.Token.IsCancellationRequested)
                {
                    if (Exit)
                    {
                        return;
                    }
                    message = "Canceled dumping " + fileName;
                }
                else if (IsError)
                {
                    message = "An error occurred while dumping " + fileName;
                }
                else
                {
                    message = "Finished dumping " + fileName;
                }
                UpdateToolstripStatus(message);
                UpdateTextBoxInfo(Info, message + ".\r\nElapsed time: " + GetDurationAsString(duration), true);
                IsError    = false;
                IsFinished = true;
                EnableButtons();
                CancelSource.Dispose();
            }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.FromCurrentSynchronizationContext());
        }
Ejemplo n.º 2
0
 private void DirectoryDumperThread(WzDirectory dir, WzXml wzxml, bool singleDump = false)
 {
     if (CancelSource.Token.IsCancellationRequested)
     {
         return;
     }
     try {
         wzxml.DumpDir(dir);
         if (!singleDump && !CancelSource.Token.IsCancellationRequested)
         {
             UpdateTextBoxInfo(Info, "Finished dumping " + dir.Name, true);
         }
     } catch (Exception ex) {
         if (!CancelSource.Token.IsCancellationRequested)
         {
             UpdateTextBoxInfo(Info, dir.Name + " Exception: " + ex.Message + " " + ex.StackTrace, true);
             IsError = true;
         }
     } finally {
         dir.Dispose();
     }
 }