title: Referencing Web/site objects in sharepoint for Timer Jobs
body: <p>Which is the best way to reference current site/web in sharepoint specially for Timer Jobs from the examples given below and why?</p>
  
  <p>Example1:</p>
  
  <pre><code>SPWebApplication webApp = this.Parent as SPWebApplication; SPWeb oWeb = webApp.Sites[0].RootWeb;
  </code></pre>
  
  <p>OR</p>
  
  <p>Example2: </p>
  
  <pre><code>using(SPSite site=new SPSite(SPCOntext.Current.Web.Url)){ using(SPWeb web=site.OpenWeb()){
  
  } }
  </code></pre>