Thursday, March 22, 2012

Wait Page

I have an stored procedure which takes long time to execute. So I am trying
to execute the procedure in another thread by using the thread start
function. After the SP starts processing I want to take the user to a "wait"
page and then return them after the processing is over.

The wait page has http-refresh header which takes it back to the starting
page. Once the starting page has reloaded in page_load procedure I would
like to check whether the processing has finished and if not redirect back to
the wait page.

Problem is I do not know how to pass data back to the application main
thread from the secondary thread. I tried using session using
synchlock.Session, but it errors out.

I also tried to use a callback. But since the callback procedure also
executes in a secondary thread I am getting the same error.

Please helpThe simplest example I've seen for such a page is this:
http://www.aspnetpro.com/Newsletter...p200308bm_l.asp

--
I hope this helps,
Steve C. Orr, MCSD
http://SteveOrr.net

"PinellasBoy" <PinellasBoy@.discussions.microsoft.com> wrote in message
news:2F6710E8-8B9B-42DA-9AC3-CE6D04886753@.microsoft.com...
>I have an stored procedure which takes long time to execute. So I am trying
> to execute the procedure in another thread by using the thread start
> function. After the SP starts processing I want to take the user to a
> "wait"
> page and then return them after the processing is over.
> The wait page has http-refresh header which takes it back to the starting
> page. Once the starting page has reloaded in page_load procedure I would
> like to check whether the processing has finished and if not redirect back
> to
> the wait page.
> Problem is I do not know how to pass data back to the application main
> thread from the secondary thread. I tried using session using
> synchlock.Session, but it errors out.
> I also tried to use a callback. But since the callback procedure also
> executes in a secondary thread I am getting the same error.
> Please help
The future will hold new options:
http://www.devx.com/dotnet/Article/26747

You also might consider using a queue and a windows service to handle such
background tasks. This design could improve scalability.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"PinellasBoy" <PinellasBoy@.discussions.microsoft.com> wrote in message
news:2F6710E8-8B9B-42DA-9AC3-CE6D04886753@.microsoft.com...
>I have an stored procedure which takes long time to execute. So I am trying
> to execute the procedure in another thread by using the thread start
> function. After the SP starts processing I want to take the user to a
> "wait"
> page and then return them after the processing is over.
> The wait page has http-refresh header which takes it back to the starting
> page. Once the starting page has reloaded in page_load procedure I would
> like to check whether the processing has finished and if not redirect back
> to
> the wait page.
> Problem is I do not know how to pass data back to the application main
> thread from the secondary thread. I tried using session using
> synchlock.Session, but it errors out.
> I also tried to use a callback. But since the callback procedure also
> executes in a secondary thread I am getting the same error.
> Please help
Thanks Steve,

I have seen variant of the same approach on couple of places on the web,
one is http://www.eggheadcafe.com/articles/20050108.asp
But this approach requires that you have two asp.net pages one starting page
other the end page where the actual processing will take place. There is
nothing wrong of this method, just I was trying to avoid to split the code on
two different pages...

"Steve C. Orr [MVP, MCSD]" wrote:

> The simplest example I've seen for such a page is this:
> http://www.aspnetpro.com/Newsletter...p200308bm_l.asp
> --
> I hope this helps,
> Steve C. Orr, MCSD
> http://SteveOrr.net
>
> "PinellasBoy" <PinellasBoy@.discussions.microsoft.com> wrote in message
> news:2F6710E8-8B9B-42DA-9AC3-CE6D04886753@.microsoft.com...
> >I have an stored procedure which takes long time to execute. So I am trying
> > to execute the procedure in another thread by using the thread start
> > function. After the SP starts processing I want to take the user to a
> > "wait"
> > page and then return them after the processing is over.
> > The wait page has http-refresh header which takes it back to the starting
> > page. Once the starting page has reloaded in page_load procedure I would
> > like to check whether the processing has finished and if not redirect back
> > to
> > the wait page.
> > Problem is I do not know how to pass data back to the application main
> > thread from the secondary thread. I tried using session using
> > synchlock.Session, but it errors out.
> > I also tried to use a callback. But since the callback procedure also
> > executes in a secondary thread I am getting the same error.
> > Please help
>
"PinellasBoy" <PinellasBoy@.discussions.microsoft.com> wrote in message
news:2F6710E8-8B9B-42DA-9AC3-CE6D04886753@.microsoft.com...
> I have an stored procedure which takes long time to execute. So I am
trying
> to execute the procedure in another thread by using the thread start
> function. After the SP starts processing I want to take the user to a
"wait"
> page and then return them after the processing is over.
> The wait page has http-refresh header which takes it back to the starting
> page. Once the starting page has reloaded in page_load procedure I would
> like to check whether the processing has finished and if not redirect back
to
> the wait page.
> Problem is I do not know how to pass data back to the application main
> thread from the secondary thread. I tried using session using
> synchlock.Session, but it errors out.
> I also tried to use a callback. But since the callback procedure also
> executes in a secondary thread I am getting the same error.
> Please help
Can you just stay on the page and make the wait portion visible (and the
rest not visible) while the server is processing. One way to check for
completed process is to use cache. You can put something in cache while
processing, check for it and continue the wait page if the cache item is
still present. Once the operation is completed, clear the cache can
redisplay. Don't know if this helps or not.

Mike

0 comments:

Post a Comment