コード例 #1
0
        protected override void Process(IProgressStatus progress)
        {
            // load the requested (or default) preset
            var presets = GetPresetName(progress);

            if (presets == null)
            {
                progress.ReportStatus("Preset did not exist in configuration.", MessageType.Error);
                return;
            }

            for (int i = 0; i < presets.Count; i++)
            {
                using (var subtask = new SubtaskProgressStatus("Syncing preset path " + new ItemReference(presets[i].Database, presets[i].Path), progress, i + 1, presets.Count))
                {
                    ProcessPreset(presets[i], subtask);
                }
            }
        }
コード例 #2
0
		protected override void Process(IProgressStatus progress)
		{
			progress.ReportStatus("Starting WebForms tasks demonstration...");

			const int subtasks = 3;
			for (int i = 1; i <= subtasks; i++)
			{
				using (var subtask = new SubtaskProgressStatus("Demonstration sub-task #" + i.ToString(CultureInfo.InvariantCulture), progress, i, subtasks + 1, false))
				{
					ExecuteTask(subtask);
				}
				progress.ReportStatus("Sub-task {0}/{1} done. Waiting a sec.", i, subtasks);
				Thread.Sleep(1000);
			}

			progress.ReportStatus("Demonstrating nested sub-tasks...");
			
			// you can also nest subtasks 
			// many times this might be used if a method that accepts an IProgressStatus itself calls sub-methods that also take an IProgressStatus
			// methods that accept an IProgressStatus should *ALWAYS* presume that their progress should be reported as 0-100 (ie that they are running in a subtask)

			using (var subtask = new SubtaskProgressStatus("Demonstration parent sub-task", progress, subtasks+1, subtasks + 1))
			{
				using (var innerSubtask = new SubtaskProgressStatus("Inner task 1", subtask, 1, 2))
				{
					ExecuteTask(innerSubtask);
				}

				using (var innerSubtask2 = new SubtaskProgressStatus("Inner task 2", subtask, 2, 2))
				{
					ExecuteTask(innerSubtask2);
				}
			}

			progress.ReportStatus("WebForms tasks demo complete.");
			progress.ReportStatus("Done.");
		}