/// <summary>
 ///		The protected onWeeklyUpdate method raises the event by invoking the
 ///		delegates.  The sender is always this, the current instance of the class.
 /// </summary>
 /// <param name="e">Event arguments for the WeeklyUpdate event.</param>
 protected virtual void onWeeklyUpdate(cWeeklyUpdateEventArgs e, bool DeadRemoved)
 {
     if (DeadRemoved)
     {
         if (WeeklyUpdateAfterRemovingDead != null)
         {
             // invoke the delegate
             WeeklyUpdateAfterRemovingDead(this, e);
         }
     }
     else
     {
         if (WeeklyUpdateBeforeRemovingDead != null)
         {
             // invoke the delegate
             WeeklyUpdateBeforeRemovingDead(this, e);
         }
     }
 }
        // *********************** private members ****************************************

        // private function for the actual weekly calls
        private bool WeeklyCalls(bool IncrementTime)
        {
            //System.Diagnostics.Debug.WriteLine("cBackground.cs: WeeklyCalls()");
            //System.Diagnostics.Debug.WriteLine("cBackground.cs: WeeklyCalls() Animals.Count = " + Animals.Count);

            cWeeklyActivityThread ActivityThread = new cWeeklyActivityThread(0, Animals.Count - 1, Animals,
                                                                             Years.CurrentYear.CurrentWeek, PreventIncest);

            ActivityThread.RunWeeklyActivities();

            // add babies to master list, attaching the event handler in each case
            //System.Diagnostics.Debug.WriteLine("cBackground.cs: WeeklyCalls() add babies");
            Animals.AddBabiesToList(new AnimalInfectedEventHandler(this.Animal_AnimalInfected));

            // apply any strategies applicable to this year and week
            if (StrategyCounter < Strategies.Count)
            {
                for (; ;)
                {
                    cStrategy CurrentStrategy = Strategies[StrategyCounter];
                    // if the most current strategy should be applied later, exit now
                    if (CurrentStrategy.Year > Years.CurrentYearNum || CurrentStrategy.Week > Years.CurrentYear.CurrentWeek)
                    {
                        break;
                    }
                    // if the most current strategy should be applied now, apply it!!
                    else if (CurrentStrategy.Year == Years.CurrentYearNum && CurrentStrategy.Week == Years.CurrentYear.CurrentWeek)
                    {
                        CurrentStrategy.ApplyStrategy();
                    }
                    // increment the StrategyCounter
                    StrategyCounter++;
                    // make sure we have not just run the last strategy
                    if (StrategyCounter >= Strategies.Count)
                    {
                        break;
                    }
                }
            }
            // indicate that weekly events have been run
            //System.Diagnostics.Debug.WriteLine("cBackground.cs: WeeklyCalls() indicate that weekly events have been run");
            mvarHaveRunWeeklyEvents = true;

            // raise the WeeklyUpdate event before the dead are removed
            //System.Diagnostics.Debug.WriteLine("cBackground.cs: WeeklyCalls(): raise weekly event before dead are removed");
            cWeeklyUpdateEventArgs e = new cWeeklyUpdateEventArgs(this);

            onWeeklyUpdate(e, false);

            //if (e.Abort) return false;
            //System.Diagnostics.Debug.WriteLine("cBackground.cs: WeeklyCalls(): e.Abort = " + e.Abort);
            if (e.Abort)
            {
                return(false);
            }
            // remove dead animals from main list
            Animals.RemoveDeceased();

            // raise weekly event after dead are removed
            //System.Diagnostics.Debug.WriteLine("cBackground.cs: WeeklyCalls(): raise weekly event AFTER dead are removed");
            onWeeklyUpdate(e, true);
            if (e.Abort)
            {
                return(false);
            }
            // scramble the animals
            if (ScrambleList)
            {
                Animals.ScrambleOrder();
            }
            // increment time
            if (IncrementTime)
            {
                Years.IncrementTime();
                // indicate that weekly events have not been run
                mvarHaveRunWeeklyEvents = false;
            }
            //System.Diagnostics.Debug.WriteLine("cBackground.cs: WeeklyCalls() END");
            return(true);
        }