I need a thread that loads the content of a database table in the cache
(System.Web.Caching.Cache)
i wrote therefore the code below:
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.GetConnectionSt ring,CommandType.Text,"select
* from table");
HttpContext.Current.Cache.Insert("data",ds.Table[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.F romHours(2));
t = new Thread(new ThreadStart(ThreadProc));
t.Start();
Thread.Sleep(3600);
}
.....
......
.......
public void ThreadProc()
{
try
{
DataSet
ds=SqlHelper.ExecuteDataset(Global.GetConnectionSt ring,CommandType.Text,"select
* from Table");
HttpContext.Current.Cache.Insert("data",ds.Tables[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.F romHours(2));
}
catch(Exception ex)
{
string str = ex.Message; // get the exeption as a string
}
....
......
.....
But!!!
This cause the exception: "object reference not set to an instance of
anobject"
Can someone tell me what i'm doing wrong?
Many thanks in advance
JB 3 4939
Hi,
What is the line that gives you that error?
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"jensen bredal" <je***********@yahoo.dk> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... I need a thread that loads the content of a database table in the cache (System.Web.Caching.Cache)
i wrote therefore the code below:
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.GetConnectionSt ring,CommandType.Text,"select * from table");
HttpContext.Current.Cache.Insert("data",ds.Table[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.F romHours(2));
t = new Thread(new ThreadStart(ThreadProc));
t.Start(); Thread.Sleep(3600);
} ....
.....
......
public void ThreadProc()
{
try
{
DataSet ds=SqlHelper.ExecuteDataset(Global.GetConnectionSt ring,CommandType.Text,"select * from Table");
HttpContext.Current.Cache.Insert("data",ds.Tables[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.F romHours(2));
}
catch(Exception ex)
{
string str = ex.Message; // get the exeption as a string
}
...
.....
.... But!!!
This cause the exception: "object reference not set to an instance of anobject" Can someone tell me what i'm doing wrong? Many thanks in advance
JB
in "ThreadProc" the line:
HttpContext.Current.Cache.Insert("data",ds.Table[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.F romHours(2));
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:ON**************@TK2MSFTNGP15.phx.gbl... Hi,
What is the line that gives you that error?
cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "jensen bredal" <je***********@yahoo.dk> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... I need a thread that loads the content of a database table in the cache (System.Web.Caching.Cache)
i wrote therefore the code below:
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.GetConnectionSt ring,CommandType.Text,"select * from table");
HttpContext.Current.Cache.Insert("data",ds.Table[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.F romHours(2));
t = new Thread(new ThreadStart(ThreadProc));
t.Start(); Thread.Sleep(3600);
} ....
.....
......
public void ThreadProc()
{
try
{
DataSet ds=SqlHelper.ExecuteDataset(Global.GetConnectionSt ring,CommandType.Text,"select * from Table");
HttpContext.Current.Cache.Insert("data",ds.Tables[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.F romHours(2));
}
catch(Exception ex)
{
string str = ex.Message; // get the exeption as a string
}
...
.....
.... But!!!
This cause the exception: "object reference not set to an instance of anobject" Can someone tell me what i'm doing wrong? Many thanks in advance
JB
Your cache object is null most probably. Try passing in a reference to the
cache object to your thread.
--
Regards,
Alvin Bruney - ASP.NET MVP
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
"jensen bredal" <je***********@yahoo.dk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... in "ThreadProc" the line:
HttpContext.Current.Cache.Insert("data",ds.Table[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.F romHours(2));
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:ON**************@TK2MSFTNGP15.phx.gbl... Hi,
What is the line that gives you that error?
cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "jensen bredal" <je***********@yahoo.dk> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... I need a thread that loads the content of a database table in the cache (System.Web.Caching.Cache)
i wrote therefore the code below:
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.GetConnectionSt ring,CommandType.Text,"select * from table");
HttpContext.Current.Cache.Insert("data",ds.Table[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.F romHours(2));
t = new Thread(new ThreadStart(ThreadProc));
t.Start(); Thread.Sleep(3600);
} ....
.....
......
public void ThreadProc()
{
try
{
DataSet ds=SqlHelper.ExecuteDataset(Global.GetConnectionSt ring,CommandType.Text,"select * from Table");
HttpContext.Current.Cache.Insert("data",ds.Tables[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.F romHours(2));
}
catch(Exception ex)
{
string str = ex.Message; // get the exeption as a string
}
...
.....
.... But!!!
This cause the exception: "object reference not set to an instance of anobject" Can someone tell me what i'm doing wrong? Many thanks in advance
JB
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tomaz Koritnik |
last post by:
Hi
I still have problem with this. I wan't to execute a method in main thread
after worker thread completes some work. In GUI application I'd use
Control.Invoke (control would be the main form),...
|
by: Jack Wright |
last post by:
Dear All,
In my Application my WebForm calls a WebService that fires a
query...this query takes a long time to execute as a result my
WebService timesout...but this also results in my...
|
by: Elementary Penguin |
last post by:
Suppose I spawn a thread from a web method.
The thread runs a process that takes 10 minutes.
The main thread, running the web method, returns a value to the consumer
saying, "message rec'd".
...
|
by: dhow |
last post by:
I hava a simple webservice(Just sleep for 30 seconds) which is developed
using Java and deployed on WebLogic,and I aslo make a client using VB.net. In
the client I create 5 threads to call the...
|
by: Jason Chu |
last post by:
I have a webpage which uploads a big file onto access db.
if the file is say around 30 megs, it'll take around a minute for it to get
put into the access db.
I didn't want the user to wait for it,...
| |
by: Ted Ngo |
last post by:
Hi All,
Is there an example I can use to create mutli- thread for asp.net 2.0
in c#
Here is what I want to do. I have an multiple arrylist value. Array1,
Array2, Array3, Array3.
I want to...
|
by: roni schuetz |
last post by:
since a few day's i'm running around the problem that I stocked with a
change i need to do. hopefully somebody here can give me a tipp which
will be usefull to solve my problem.
I'm using a...
|
by: ryan1234 |
last post by:
My ultimate goal is to get something like "ping.exe" to re-direct it's
standardOutput in real time to an .aspx page.
I've been able to get this behavior to work just fine in a regular
console...
|
by: =?Utf-8?B?Sm9obiBT?= |
last post by:
I have a webservice that I am calling from an application running on a
Windows Mobile device, and I am coming across a problem where the thread
freezes whilst calling the webservice.
The...
|
by: Simon |
last post by:
Hi All,
I'm currently developping something where I need to use threads.
Here's the basic scenario. I have a WebService requests which need to
launch a few threads and wait for them to complete...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |