title: How to use Session Variable inside the Thread(Background process ) C#
body: <p>I have an Issue in Storing data in <strong>Session</strong> inside the <strong>Thread(Background Process)</strong></p>
  
  <pre><code> DataTable dtmultifamilyurlvalues = new DataTable();
                      dtmultifamilyurlvalues.Columns.Add("FamilyHomes");
                      dtmultifamilyurlvalues.Columns.Add("AllListiedCurrent");
                      dtmultifamilyurlvalues.Columns.Add("AllListiedTrend");
                      dtmultifamilyurlvalues.Columns.Add("BottomCurrent");
                      dtmultifamilyurlvalues.Columns.Add("BottomTrend");
                      dtmultifamilyurlvalues.Columns.Add("LowerCurrent");
                      dtmultifamilyurlvalues.Columns.Add("LowerTrend");
                      dtmultifamilyurlvalues.Columns.Add("UpperCurrent");
                      dtmultifamilyurlvalues.Columns.Add("UpperTrend");
                      dtmultifamilyurlvalues.Columns.Add("TopCurrent");
                      dtmultifamilyurlvalues.Columns.Add("TopTrend");
  
                      //House Size
                      dtmultifamilyurlvalues.Rows.Add("Median House Size", Getmedian(familtypevalue, "a", "Sqft:MEDIAN"), GetTrends(familtypevalue, "a", "Sqft:MEDIAN_trend") + " " + GetTrends(familtypevalue, "a", "Sqft:MEDIAN_trend_strength"),
                          Getmedian(familtypevalue, "b", "Sqft:MEDIAN"), GetTrends(familtypevalue, "b", "Sqft:MEDIAN_trend") + " " + GetTrends(familtypevalue, "b", "Sqft:MEDIAN_trend_strength"),
                          Getmedian(familtypevalue, "l", "Sqft:MEDIAN"), GetTrends(familtypevalue, "l", "Sqft:MEDIAN_trend") + " " + GetTrends(familtypevalue, "l", "Sqft:MEDIAN_trend_strength"),
                          Getmedian(familtypevalue, "u", "Sqft:MEDIAN"), GetTrends(familtypevalue, "u", "Sqft:MEDIAN_trend") + " " + GetTrends(familtypevalue, "u", "Sqft:MEDIAN_trend_strength"),
                          Getmedian(familtypevalue, "t", "Sqft:MEDIAN"), GetTrends(familtypevalue, "t", "Sqft:MEDIAN_trend") + " " + GetTrends(familtypevalue, "t", "Sqft:MEDIAN_trend_strength"));
  
  
   HttpContext.Current.Session["datatablevalues"] = dtmultifamilyurlvalues;
   //HttpRuntime.Cache.Insert("multifamilyAltos", dtmultifamilyurlvalues,null,System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 60), System.Web.Caching.CacheItemPriority.Default,null);
                  });
              Multifamily.IsBackground = true;
              Multifamily.Start();
  </code></pre>
  
  <p>This Through an error object reference error,</p>
  
  <p>And I had used HttpRuntime.Cache also but when i run in two systems it produces same results it should be different based on the input(I think it is overriding the value)</p>
  
  <p>And i searched to web and know that httpcontext can't be work inside the Thread.</p>
  
  <p>So,Please tell me a solution for this Issue.</p>