Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Access Application Object From A Thread?

Reply
Thread Tools

Access Application Object From A Thread?

 
 
Al Cohen
Guest
Posts: n/a
 
      01-09-2004
We've got a few methods that take a long time to complete. We're in the
process of starting to launch these as separate threads, and having the
web form refresh every few seconds to report the method's progress.
Communication between "new" thread and web page is via the Session
object. (Not rocket science so far.)

The first problem that we ran into was that our methods could not see
the Session object anymore once they were placed in a seperate thread.
After Googling for a fix, we remedied this by passing a Session
reference to the methods that we need to use. This was somewhat of a
pain as we had to rewrite a library to take the Session reference as a
parameter. But it works.

Now we're finding that we also cannot see the Application object from
our newly-threaded methods. I suppose that we could pass a reference to
the Application object whenever it's needed, but this will be pretty
painful in terms of rewriting code - we have a lot of stuff cached in
the Application object.

So, my question: is there some other way that we can access the
Application from our threads that is more elegant than changing our
libraries to require a reference to be explicitly passed?

Thanks!

Al Cohen

 
Reply With Quote
 
 
 
 
Hermit Dave
Guest
Posts: n/a
 
      01-09-2004
System.Web.HttpContext.Current.Application should get you the application
object from anywhere....
System.Web.HttpContext.Current.System is also available..

I had some issues getting the context but most people on the ng... just get
it fine...

--
Regards,

HD

"Al Cohen" <(E-Mail Removed)-o-r-n-e-l-l.edu> wrote in message
news(E-Mail Removed)...
> We've got a few methods that take a long time to complete. We're in the
> process of starting to launch these as separate threads, and having the
> web form refresh every few seconds to report the method's progress.
> Communication between "new" thread and web page is via the Session
> object. (Not rocket science so far.)
>
> The first problem that we ran into was that our methods could not see
> the Session object anymore once they were placed in a seperate thread.
> After Googling for a fix, we remedied this by passing a Session
> reference to the methods that we need to use. This was somewhat of a
> pain as we had to rewrite a library to take the Session reference as a
> parameter. But it works.
>
> Now we're finding that we also cannot see the Application object from
> our newly-threaded methods. I suppose that we could pass a reference to
> the Application object whenever it's needed, but this will be pretty
> painful in terms of rewriting code - we have a lot of stuff cached in
> the Application object.
>
> So, my question: is there some other way that we can access the
> Application from our threads that is more elegant than changing our
> libraries to require a reference to be explicitly passed?
>
> Thanks!
>
> Al Cohen
>



 
Reply With Quote
 
 
 
 
Al Cohen
Guest
Posts: n/a
 
      01-09-2004
System.Web.HttpContext.Current.Application is exactly what we're
doing... and it works fine from the main application thread, but returns
null from any threads launched from the main application thread.

At the risk of being stupid, what is
System.Web.HttpContext.Current.System? I tried it, and Visual Studio
and Google both get confused?

Thanks,

Al

Hermit Dave wrote:

> System.Web.HttpContext.Current.Application should get you the application
> object from anywhere....
> System.Web.HttpContext.Current.System is also available..
>
> I had some issues getting the context but most people on the ng... just get
> it fine...
>


 
Reply With Quote
 
Hermit Dave
Guest
Posts: n/a
 
      01-09-2004
Sorry mate couldnt find any member call System in Context object...

http://msdn.microsoft.com/library/de...mberstopic.asp

as for not getting session object as a part of secondary threads... never
had to do that.... see what other say

--
Regards,

HD

"Al Cohen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> System.Web.HttpContext.Current.Application is exactly what we're
> doing... and it works fine from the main application thread, but returns
> null from any threads launched from the main application thread.
>
> At the risk of being stupid, what is
> System.Web.HttpContext.Current.System? I tried it, and Visual Studio
> and Google both get confused?
>
> Thanks,
>
> Al
>
> Hermit Dave wrote:
>
> > System.Web.HttpContext.Current.Application should get you the

application
> > object from anywhere....
> > System.Web.HttpContext.Current.System is also available..
> >
> > I had some issues getting the context but most people on the ng... just

get
> > it fine...
> >

>



 
Reply With Quote
 
Al Cohen
Guest
Posts: n/a
 
      01-10-2004
Aha! Problem solved!

Added a reference to the Application object in a static method: it's
available from my threads.


Al Cohen wrote:
> We've got a few methods that take a long time to complete. We're in the
> process of starting to launch these as separate threads, and having the
> web form refresh every few seconds to report the method's progress.
> Communication between "new" thread and web page is via the Session
> object. (Not rocket science so far.)
>
> The first problem that we ran into was that our methods could not see
> the Session object anymore once they were placed in a seperate thread.
> After Googling for a fix, we remedied this by passing a Session
> reference to the methods that we need to use. This was somewhat of a
> pain as we had to rewrite a library to take the Session reference as a
> parameter. But it works.
>
> Now we're finding that we also cannot see the Application object from
> our newly-threaded methods. I suppose that we could pass a reference to
> the Application object whenever it's needed, but this will be pretty
> painful in terms of rewriting code - we have a lot of stuff cached in
> the Application object.
>
> So, my question: is there some other way that we can access the
> Application from our threads that is more elegant than changing our
> libraries to require a reference to be explicitly passed?
>
> Thanks!
>
> Al Cohen
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help need to access VB application from web application SMS ASP General 1 10-03-2006 08:11 AM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
Application/Object reference not set to an instance of an object Andrew ASP .Net 1 08-08-2005 10:25 PM
COM object accessing asp Application object mrrrk ASP .Net 1 12-19-2003 09:37 AM
What issue will HIT me hard when I convert an Access 2002 MDE application to Web Application? Sean ASP .Net 2 08-07-2003 07:13 AM



Advertisments