Persisting state in Sharepoint timer job definitions

Using class member variables will not work if you want to persist state between invocations. This seems to be due to the way sharepoint manages timer jobs. A solution is to use the Properties *property* which is exposed to all SPJobDefinition subtypes. This is a hashtable which accepts a key value pair. Usage:

1public class SampleTimerJob : SPJobDefinition {     public SampleTimerJob(string jobName, SPWebApplication webApplication, string url, string email)         : base(jobName, webApplication, null, SPJobLockType.ContentDatabase)     {         ContainerSite = url;         Email = email;          this.Title = "sample timer";     }      public string ContainerSite     {         get { return Properties\["site"\].ToString(); }         set { Properties\["site"\] = value; }     }      public string Email     {         get { return Properties\["email"\].ToString(); }         set { Properties\["email"\] = value; }     }      public override void Execute(Guid targetInstanceId)     {         SPSite site = new SPSite(ContainerSite);          using (SPWeb web = site.OpenWeb())         {              SPUtility.SendEmail(web, false, false, Email,                                 "title",                                 "content");         }     } }