locked
Best way to "Set and forget a long running sub?" RRS feed

  • Question

  • User-234661480 posted

    Hi all,

    Wasent too sure where i should post this, but here it goes: Basically i have a webpage, from the web page i want to launch an (asyncronous?) task. This task involves getting info from other servers, database, and file access etc... Basically it could takea while to complete (Compared to the speed i want the page to load at).

    Heres the thing: The content of the page being displayed does not depend on the data being fetched/manipulated by the function. Therefore, i want the page to simply call the sub, and continue rendering and serving the client, without having to wait for the process to complete in order to show data. So basically, after the function is called there will be no more communication between the initial page and the sub that is called, the sub will simply finish up, and "go away."

    Is this possible? If it is, how should i implement this? Can Asynchronous calls handle this? Or must i use something else?

    Again, i basically want the page to call the method, but not be slowed down direcly from the methods running (ie having to wait for it to complete.)

    Thanks Alot!

    Mobius5150

    Monday, November 30, 2009 11:42 PM

All replies

  • User78336405 posted

    Hi,

    From your description, I think HttpModule will be your selection.  HttpModule is an event based methodology to inject pre-processing logic before any resource is requested. When any client sends a request for a resource, the request pipeline emits a lot of events. And you could insert what you want to do.

    Wednesday, December 2, 2009 12:57 AM
  • User-234661480 posted

    Hi - Thanks for your response.

    If i were to use an HttpModule, would i be able to have a long running sub that would not slow down page load?

    Ie if i called sub New(), and it would take a year to complete (exaggeration here), would the page take a year to load, or would it load as normal?

    Thanks,

    Mobius5150 

    Thursday, December 3, 2009 10:20 AM
  • User78336405 posted

    Hi,

     You could write more HttpModules and manage the sub task separately. For more about HttpMoudle, please refer:http://www.codeproject.com/KB/aspnet/HttpModuleandHttpHandle.aspx

    Thursday, December 3, 2009 9:19 PM