Example #1
0
        private void DoRestoreJob(RestoreJob job)
        {
            List<Task> tasks = new List<Task>();
            XDocument doc = XDocument.Load(job.MetadataFilePath);
            foreach (XElement fileElement in doc.Element("BackupSet").Elements())
            {

                FileRestoreTask restoreTask = new FileRestoreTask(fileElement.Attribute("local").Value, fileElement.Attribute("remote").Value);
                Task task = Task<ResultType<RestoreItem>>.Factory.StartNew(() =>
                    {
                        lock (syncRoot)
                        {
                            totalTasks++;
                            fireProgressEvent();
                        }
                        return job.ProcessChain.Process(restoreTask);
                    }).ContinueWith((t) =>
                        {
                            lock (syncRoot)
                            {
                                doneTasks++;
                                fireProgressEvent();
                            }
                        });
                tasks.Add(task);
            }
            Task.WaitAll(tasks.ToArray());
            if (JobDone != null)
            {
                JobDone(this, new JobDoneEventArgs());
            }
            return;
        }
Example #2
0
 public void SubmitRestoreJob(RestoreJob restoreJob)
 {
     jobExecution = Task.Factory.StartNew(() => DoRestoreJob(restoreJob));
 }