Changeset 213
- Timestamp:
- 3/11/2008 2:53:20 AM (5 years ago)
- Location:
- branches/eraser6/Manager
- Files:
-
- 2 edited
-
DirectExecutor.cs (modified) (5 diffs)
-
Task.cs (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Manager/DirectExecutor.cs
r208 r213 20 20 thread = new Thread(delegate() 21 21 { 22 this.Main();22 Main(); 23 23 }); 24 24 … … 39 39 if (unusedIds.Count != 0) 40 40 { 41 task. ID= unusedIds[0];41 task.id = unusedIds[0]; 42 42 unusedIds.RemoveAt(0); 43 43 } 44 44 else 45 task. ID= ++nextId;45 task.id = ++nextId; 46 46 } 47 47 … … 119 119 try 120 120 { 121 //Broadcast the task started event. 122 task.OnTaskStarted(new TaskEventArgs(task)); 123 121 124 //Run the task 122 125 foreach (Task.ErasureTarget target in task.Entries) … … 143 146 task.LogEntry(new LogEntry(e.Message, LogLevel.FATAL)); 144 147 } 145 146 //If the task is a recurring task, reschedule it since we are done. 147 if (task.Schedule is RecurringSchedule) 148 ((RecurringSchedule)task.Schedule).Reschedule(DateTime.Now); 148 finally 149 { 150 //And the task finished event. 151 task.OnTaskFinished(new TaskEventArgs(task)); 152 153 //If the task is a recurring task, reschedule it since we are done. 154 if (task.Schedule is RecurringSchedule) 155 ((RecurringSchedule)task.Schedule).Reschedule(DateTime.Now); 156 } 149 157 } 150 158 … … 183 191 //Update the task progress 184 192 eventArgs.overallProgress = (i * 100) / paths.Count; 193 eventArgs.currentTarget = target; 185 194 eventArgs.currentItemName = paths[i]; 186 195 eventArgs.currentItemProgress = 0; -
branches/eraser6/Manager/Task.cs
r206 r213 174 174 { 175 175 get { return id; } 176 set { id = value; }177 176 } 178 177 … … 185 184 get { return name; } 186 185 set { name = value; } 186 } 187 188 /// <summary> 189 /// The name of the task, used for display in UI elements. 190 /// </summary> 191 public string UIText 192 { 193 get 194 { 195 //Simple case, the task name was given by the user. 196 if (Name.Length != 0) 197 return Name; 198 199 string result = string.Empty; 200 if (Entries.Count < 3) 201 //Simpler case, small set of data. 202 foreach (Task.ErasureTarget tgt in Entries) 203 result += tgt.UIText + ", "; 204 else 205 //Ok, we've quite a few entries, get the first, the mid and the end. 206 for (int i = 0; i < Entries.Count; i += Entries.Count / 3) 207 result += Entries[i].UIText + ", "; 208 return result.Substring(0, result.Length - 2); 209 } 210 } 211 212 /// <summary> 213 /// Gets the status of the task - whether it is being executed. 214 /// </summary> 215 public bool Executing 216 { 217 get { return executing; } 187 218 } 188 219 … … 228 259 } 229 260 261 #region Events 262 /// <summary> 263 /// The prototype for events handling just a task object as the event argument. 264 /// </summary> 265 /// <param name="e">The task object.</param> 266 public delegate void TaskEventFunction(TaskEventArgs e); 267 230 268 /// <summary> 231 269 /// The prototype for events handling the progress changed event. … … 235 273 236 274 /// <summary> 275 /// The start of the execution of a task. 276 /// </summary> 277 public event TaskEventFunction TaskStarted; 278 279 /// <summary> 237 280 /// The event object holding all event handlers. 238 281 /// </summary> 239 282 public event ProgressEventFunction ProgressChanged; 283 284 /// <summary> 285 /// The completion of the execution of a task. 286 /// </summary> 287 public event TaskEventFunction TaskFinished; 288 289 /// <summary> 290 /// Broadcasts the task execution start event. 291 /// </summary> 292 /// <param name="e"></param> 293 internal void OnTaskStarted(TaskEventArgs e) 294 { 295 if (TaskStarted != null) 296 TaskStarted.Invoke(e); 297 executing = true; 298 } 240 299 241 300 /// <summary> … … 249 308 } 250 309 251 private uint id; 310 /// <summary> 311 /// Broadcasts the task execution completion event. 312 /// </summary> 313 /// <param name="e"></param> 314 internal void OnTaskFinished(TaskEventArgs e) 315 { 316 if (TaskFinished != null) 317 TaskFinished.Invoke(e); 318 executing = false; 319 } 320 #endregion 321 322 internal uint id; 252 323 private string name; 324 private bool executing; 325 253 326 private Schedule schedule = Schedule.RunNow; 254 327 private List<ErasureTarget> entries = new List<ErasureTarget>(); … … 257 330 258 331 /// <summary> 332 /// A base event class for all event arguments involving a task. 333 /// </summary> 334 public class TaskEventArgs : EventArgs 335 { 336 /// <summary> 337 /// Constructor. 338 /// </summary> 339 /// <param name="task">The task being run.</param> 340 public TaskEventArgs(Task task) 341 { 342 this.task = task; 343 } 344 345 /// <summary> 346 /// The executing task. 347 /// </summary> 348 public Task Task 349 { 350 get { return task; } 351 } 352 353 private Task task; 354 } 355 356 /// <summary> 259 357 /// A Event argument object containing the progress of the task. 260 358 /// </summary> 261 public class TaskProgressEventArgs : EventArgs359 public class TaskProgressEventArgs : TaskEventArgs 262 360 { 263 361 /// <summary> 264 362 /// Constructor. 265 363 /// </summary> 364 /// <param name="task">The task being run.</param> 266 365 /// <param name="overallProgress">The overall progress of the task.</param> 267 366 /// <param name="currentItemProgress">The progress for the individual … … 269 368 public TaskProgressEventArgs(Task task, int overallProgress, 270 369 int currentItemProgress) 271 {272 this.task = task;370 : base(task) 371 { 273 372 this.overallProgress = overallProgress; 274 373 this.currentItemProgress = currentItemProgress; … … 276 375 277 376 /// <summary> 278 /// The executing task.279 /// </summary>280 public Task Task281 {282 get { return task; }283 }284 285 /// <summary>286 377 /// A number from 0 to 100 detailing the overall progress of the task. 287 378 /// </summary> … … 289 380 { 290 381 get { return overallProgress; } 382 } 383 384 /// <summary> 385 /// The current erasure target - the current item being erased. 386 /// </summary> 387 public Task.ErasureTarget CurrentTarget 388 { 389 get { return currentTarget; } 291 390 } 292 391 … … 324 423 } 325 424 326 private Task task;327 425 internal int overallProgress; 426 internal Task.ErasureTarget currentTarget; 328 427 internal int currentItemProgress; 329 428 internal string currentItemName; 330 internal int currentPass ;429 internal int currentPass = 1; 331 430 internal int totalPasses; 332 431 }
Note: See TracChangeset
for help on using the changeset viewer.
