two threads

P

polilop

I have a stored procedure in my web application that goes on for long time,
which couses IE to :
[SqlException (0x80131904): Timeout expired. The timeout period elapsed
prior to completion of the operation or the server is not responding.]

So i thought to enable the user to run the stored procedure in a background
thread (which will fill a temporary table with data), return the http
response,
which tells the user the program started. Then the user can check if the
program has finished by checking the thread.

What i need to know is how can i run a seperate thread, return http
response (postback) to the user, and allso how to check if the thread is
still running from a second/another http reqest ?
 
N

Nicholas Paldino [.NET/C# MVP]

Well, in order to do this, you will have to send some piece of
information back to the user that will allow the user to identify which
stored proc that she wants to check up on. When your thread is done, you
would place information in the Session collection (or some other collection
which is accessible to the user) keyed on the value indicated above to
indicate that the process is complete.

However, even if you run this on a separate thread, it's not going to
work. The reason for this is that you are getting a SqlException, which
indicates that the command is timing out. Just running this on another
thread will cause the exception to be thrown on that other thread.

Rather, you should set the CommandTimeout property on the SqlCommand you
are executing to a value that will be reasonable for the operation you are
performing.
 
P

polilop

Great, this solved the problem but Still the procedure lasts for long time,
and I would decide to go for the threading solution.
So is it possible what i wrote below, example or link to one would be
helpful.

thanks for help so far

Nicholas Paldino said:
Well, in order to do this, you will have to send some piece of
information back to the user that will allow the user to identify which
stored proc that she wants to check up on. When your thread is done, you
would place information in the Session collection (or some other
collection which is accessible to the user) keyed on the value indicated
above to indicate that the process is complete.

However, even if you run this on a separate thread, it's not going to
work. The reason for this is that you are getting a SqlException, which
indicates that the command is timing out. Just running this on another
thread will cause the exception to be thrown on that other thread.

Rather, you should set the CommandTimeout property on the SqlCommand
you are executing to a value that will be reasonable for the operation you
are performing.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

polilop said:
I have a stored procedure in my web application that goes on for long
time,
which couses IE to :
[SqlException (0x80131904): Timeout expired. The timeout period elapsed
prior to completion of the operation or the server is not responding.]

So i thought to enable the user to run the stored procedure in a
background
thread (which will fill a temporary table with data), return the http
response,
which tells the user the program started. Then the user can check if the
program has finished by checking the thread.

What i need to know is how can i run a seperate thread, return http
response (postback) to the user, and allso how to check if the thread is
still running from a second/another http reqest ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top