示例#1
0
        public ProgressTask AddSubTask(string subtask, int totalPoints)
        {
            if (_subtasks.ContainsKey(subtask))
            {
                throw new ArgumentException();
            }

            ProgressTask taskitem = new ProgressTask(totalPoints);

            _subtasks.Add(subtask, taskitem);
            _subtaskPoints += totalPoints;
            return(taskitem);
        }
示例#2
0
		public ProgressTask AddSubTask(string subtask, int totalPoints)
		{
			if (_subtasks.ContainsKey(subtask))
				throw new ArgumentException();

			ProgressTask taskitem = new ProgressTask(totalPoints);
			_subtasks.Add(subtask, taskitem);
			_subtaskPoints += totalPoints;
			return taskitem;
		}
示例#3
0
		private void LoadVolume(IBackgroundTaskContext context)
		{
			try
			{
				ProgressTask mainTask = new ProgressTask();
				mainTask.AddSubTask("BUILD", 90);
				mainTask.AddSubTask("LAYOUT", 10);

				context.ReportProgress(new BackgroundTaskProgress(mainTask.IntPercent, string.Format(SR.MessageInitializingMpr, mainTask.Progress)));

				BackgroundTaskParams @params = (BackgroundTaskParams) context.UserState;
				Volume volume = Volume.Create(@params.Frames,
				                                    delegate(int i, int count)
				                                    	{
				                                    		if (context.CancelRequested)
				                                    			throw new BackgroundTaskCancelledException();
				                                    		if (i == 0)
				                                    			mainTask["BUILD"].AddSubTask("", count);
				                                    		mainTask["BUILD"][""].Increment();
				                                    		string message = string.Format(SR.MessageBuildingMprVolumeProgress, mainTask.Progress, i + 1, count, mainTask["BUILD"].Progress);
				                                    		context.ReportProgress(new BackgroundTaskProgress(mainTask.IntPercent, message));
				                                    	});

				mainTask["BUILD"].MarkComplete();
				context.ReportProgress(new BackgroundTaskProgress(mainTask.IntPercent, string.Format(SR.MessagePerformingMprWorkspaceLayout, mainTask.Progress)));

				//call layout here b/c it could take a while
				@params.SynchronizationContext.Send(delegate
				                                    	{
															_viewer = new MprViewerComponent(volume);
															_viewer.Layout();
				                                    	}, null);

				mainTask["LAYOUT"].MarkComplete();
				context.ReportProgress(new BackgroundTaskProgress(mainTask.IntPercent, string.Format(SR.MessageDone, mainTask.Progress)));

				context.Complete();
			}
			catch (BackgroundTaskCancelledException)
			{
				context.Cancel();
			}
			catch (Exception ex)
			{
				context.Error(ex);
			}
		}