public class Global : System.Web.HttpApplication
{
....
.....
.....
public static Thread t;
{
get { return post; }
}
public Global()
{
InitializeComponent();
}
public static String GetConnectionString
{
get { return ConfigurationSettings.AppSettings["DBConnStr"]; }
}
protected void Application_Start(Object sender, EventArgs e)
{
DataSet
ds=SqlHelper.ExecuteDataset(Global.GetConnectionString,CommandType.Text,"select
* from table");
HttpContext.Current.Cache.Insert("data",ds.Table[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.FromHours(2));
t = new Thread(new ThreadStart(ThreadProc));
t.Start();
Thread.Sleep(3600);
}
....
.....
......
public void ThreadProc()
{
try
{
DataSet
ds=SqlHelper.ExecuteDataset(Global.GetConnectionString,CommandType.Text,"select
* from Table");
HttpContext.Current.Cache.Insert("data",ds.Tables[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.FromHours(2));
}
catch(Exception ex)
{
string str = ex.Message; // get the exeption as a string
}
...
.....
....
I want to create a thread that load the content of a database table into the
application cache.
But!!!
This cause the exception: "object reference not set to an instance of
anobject"
Can any someone tell me what i'm doing wrong?
Many thanks in advance
JB
Chad Z. Hower aka Kudzu - 11 May 2005 13:14 GMT
> This cause the exception: "object reference not set to an instance of
> anobject"
Why not debug it and find out what line its occuring on first?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Blog: http://blogs.atozed.com/kudzu
jensen bredal - 11 May 2005 13:48 GMT
well the excepton occurs in "public void ThreadProc()"
on
Chad Z. Hower aka Kudzu - 11 May 2005 17:00 GMT
> well the excepton occurs in "public void ThreadProc()"
You need to narrow it down further. DEBUG it. Put a break point on the first
line. Now step thorugh and find out what line trips it. Then do it again, and
set watches till you find out what object is null.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Blog: http://blogs.atozed.com/kudzu