Ignore:
Timestamp:
6/3/2009 3:55:56 AM (6 years ago)
Author:
lowjoel
Message:

A whole host of scheduler fixes:

  • When cancelling scheduled tasks we removed the scheduled version of the task as well so tasks will no longer run on the schedule
  • When editing tasks the schedules were not updated and scheduled tasks still ran on the old schedule
  • Determining whether the task was queued manually for execution was a little unpredictable, this is now fixed
  • For consistency, when tasks are queued we will prevent editing of tasks

And a few stylistic fixes

  • Do not catch general exception types
  • Use automatic properties where possible
  • Don't use multiple casts
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.Manager/Task.cs

    r1085 r1102  
    4747            Targets.Owner = this; 
    4848            Log = (Logger)info.GetValue("Log", typeof(Logger)); 
     49            Canceled = false; 
    4950 
    5051            Schedule schedule = (Schedule)info.GetValue("Schedule", typeof(Schedule)); 
     
    8081            Targets = new ErasureTargetsCollection(this); 
    8182            Schedule = Schedule.RunNow; 
     83            Canceled = false; 
    8284            Log = new Logger(); 
    8385        } 
     
    138140        /// executor is idle. 
    139141        /// </summary> 
    140         public bool Queued { get; internal set; } 
     142        public bool Queued 
     143        { 
     144            get 
     145            { 
     146                return Executor.IsTaskQueued(this); 
     147            } 
     148        } 
    141149 
    142150        /// <summary> 
     
    153161        /// The schedule for running the task. 
    154162        /// </summary> 
    155         public Schedule Schedule { get; set; } 
     163        public Schedule Schedule 
     164        { 
     165            get 
     166            { 
     167                return schedule; 
     168            } 
     169            set 
     170            { 
     171                if (schedule.Owner != null) 
     172                    throw new ArgumentException(S._("The schedule provided can only " + 
     173                        "belong to one task at a time")); 
     174 
     175                if (schedule is RecurringSchedule) 
     176                    ((RecurringSchedule)schedule).Owner = null; 
     177                schedule = value; 
     178                if (schedule is RecurringSchedule) 
     179                    ((RecurringSchedule)schedule).Owner = this; 
     180                OnTaskEdited(); 
     181            } 
     182        } 
    156183 
    157184        /// <summary> 
     
    160187        public Logger Log { get; private set; } 
    161188 
     189        private Schedule schedule; 
     190 
    162191        #region Events 
    163192        /// <summary> 
     193        /// The task has been edited. 
     194        /// </summary> 
     195        public EventHandler<TaskEventArgs> TaskEdited { get; set; } 
     196 
     197        /// <summary> 
    164198        /// The start of the execution of a task. 
    165199        /// </summary> 
     
    175209        /// </summary> 
    176210        public EventHandler<TaskEventArgs> TaskFinished { get; set; } 
     211 
     212        /// <summary> 
     213        /// Broadcasts the task edited event. 
     214        /// </summary> 
     215        internal void OnTaskEdited() 
     216        { 
     217            if (TaskEdited != null) 
     218                TaskEdited(this, new TaskEventArgs(this)); 
     219        } 
    177220 
    178221        /// <summary> 
     
    613656                        result.AddRange(GetFiles(dir)); 
    614657                    } 
    615                     catch (Exception e) 
     658                    catch (DirectoryNotFoundException e) 
    616659                    { 
    617660                        //Ignore, but log. 
     
    720763                foreach (FileSystemInfo fsInfo in info.GetFileSystemInfos()) 
    721764                { 
    722                     if (fsInfo is FileInfo) 
     765                    FileInfo fileInfo = fsInfo as FileInfo; 
     766                    if (fileInfo != null) 
    723767                    { 
    724                         totalSize += ((FileInfo)fsInfo).Length; 
    725                         GetPathADSes(paths, out totalSize, fsInfo.FullName); 
    726                         paths.Add(fsInfo.FullName); 
     768                        totalSize += fileInfo.Length; 
     769                        GetPathADSes(paths, out totalSize, fileInfo.FullName); 
     770                        paths.Add(fileInfo.FullName); 
    727771                    } 
    728772                    else 
Note: See TracChangeset for help on using the changeset viewer.