Exemplo n.º 1
0
        private void Start()
        {
            var startInfo = new ProcessStartInfo
            {
                FileName               = TaskSetup.Executable,
                Arguments              = TaskSetup.GetCmdLineParams(),
                WorkingDirectory       = _workingDir,
                UseShellExecute        = false,
                CreateNoWindow         = true,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                RedirectStandardError  = true
            };

            using (var process = new Process())
            {
                process.StartInfo           = startInfo;
                process.ErrorDataReceived  += new DataReceivedEventHandler(OnErrorDataReceived);
                process.OutputDataReceived += new DataReceivedEventHandler(OnOutputDataReceived);
                process.Start();
                process.BeginErrorReadLine();
                process.BeginOutputReadLine();
                process.WaitForExit();
                IsFinished = true;
                if (TaskFinishedCallback == null)
                {
                    return;
                }
                TaskFinishedCallback();
            }
        }
Exemplo n.º 2
0
 public MagickTask(TaskSetup setup)
 {
     Id          = Guid.NewGuid();
     TaskSetup   = setup;
     _workingDir = new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName;
     _progress   = new MagickProgress(args => ConvertProgressEvent(this, args));
 }
Exemplo n.º 3
0
        public void Convert(TaskSetup setup)
        {
            var task = new MagickTask(setup);

            task.TaskFinishedCallback += () => TaskFinished(setup);
            task.ConvertFinishedEvent += ConvertFinished;
            task.ConvertProgressEvent += ConvertProgress;
            _queue.EnqueueTask(task);
        }
Exemplo n.º 4
0
 public virtual void TaskFinished(TaskSetup setup)
 {
     if (!string.IsNullOrWhiteSpace(setup.Source))
     {
         File.Delete(setup.Source);
     }
     if (setup.CompletedCallBack != null)
     {
         setup.CompletedCallBack(setup);
     }
 }
Exemplo n.º 5
0
 public static bool GainedDuration(object sender, ConvertProgressEventArgs eargs, out TaskSetup setup)
 {
     if (eargs.IsGainedDuration)
     {
         if (sender is MagickTask)
         {
             setup = (sender as MagickTask).TaskSetup;
             return(true);
         }
         setup = null;
         return(true);
     }
     setup = null;
     return(false);
 }
Exemplo n.º 6
0
 public static bool ProgressCompleted(object sender, ConvertProgressEventArgs eargs, out TaskSetup setup)
 {
     if (eargs.IsCompleted)
     {
         if (sender is MagickTask)
         {
             setup = (sender as MagickTask).TaskSetup;
             return(true);
         }
         setup = null;
         return(true);
     }
     setup = null;
     return(false);
 }