By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,157 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,157 IT Pros & Developers. It's quick & easy.

"Thread was being aborted" error from WebApp using Thread.Sleep.

P: n/a
I have an ASP.Net application that sends a NetworkStream to a .Net
Service, which has a TcpListener listening on a port for the ASP.Net
client. When it receives a request it creates a new thread with the
AddressOf a class that runs a long data intensive process that can
take between 1-15 minutes and results in the creation of a uniquely
named file.

Meanwhile, I want my ASP.Net application to sit and wait until the
file appears at a given location (signalling that the worker thread
has ended) and then resume processing. I have built a .Net Service to
handle this processing because I was finding that IIS was running into
memory problems, when processing multiple requests.

Anyway, my problem is getting the ASP.Net to wait and then resume when
the file appears. To prevent timeout, I have added '<httpRuntime
executionTimeout="10000">' to the Web.Config file I also modified the
ASP Script timeout in IIS (Select virtual directory > 'Properties' >
'Configuration' button >'App Options' tab) and set that to 10000
seconds.

1. I have experimented with a FileSystemWatcher:

'-- Suspend processing until file appears
Dim oWatcher As New FileSystemWatcher('c:\myPath\', 'myFile.dat')
Dim oResult As WaitForChangedResult
oResult = oWatcher.WaitForChanged(Created)
'-- Resume processing

.... and this works fine for the first request, but fails for any
subsequent concurrent requests, hanging at the WaitForChanged event
long after the file is created. I have also found that if a large file
is being created the WaitForChanged event is triggered before the file
is finished writing to disk, resulting in (trappable) file access
errors.
2. I though it might then be easier to simply use a Do Loop, checking
until the File.Exists is true, with a Thread.Sleep(1000) for each
iteration:

'-- loop until file appears
Dim iSeconds As Long
Do Until File.Exists("c:\myPath\myFile.dat") = True
iSeconds += 1
Threading.Thread.Sleep(1000) '-- Sleep for 1 second
Loop
'-- Resume processing

.... however, I am finding that after 60-90 seconds, this fails on the
Thread.Sleep(1000) line, with the error message "Thread was being
aborted".

I am also finding that when this error throws to an exception, the
asp.net app appears to hang. In the catch block I have a simple
response.write to return the error message and I have tried adding a
response.end, but it won't die.
So my question is, what is the best way to suspend processing in an
asp.net application (for between 1-15 minutes), while a file is
generated by another process.

Thanks,

Stephen
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Instead of suspending a processing in asp.net why don't u redirect to a other aspx where it shows ur message is "ur request is processing ....." and refresh this page for every 1 min,get the status value whether file is generated or not ,if status is generated ...show normal page instead of processing page otherwise show processing...
to get status value ....create one globalvalue or update database table with status column after file is generated.


"Stephen Miller" wrote:
I have an ASP.Net application that sends a NetworkStream to a .Net
Service, which has a TcpListener listening on a port for the ASP.Net
client. When it receives a request it creates a new thread with the
AddressOf a class that runs a long data intensive process that can
take between 1-15 minutes and results in the creation of a uniquely
named file.

Meanwhile, I want my ASP.Net application to sit and wait until the
file appears at a given location (signalling that the worker thread
has ended) and then resume processing. I have built a .Net Service to
handle this processing because I was finding that IIS was running into
memory problems, when processing multiple requests.

Anyway, my problem is getting the ASP.Net to wait and then resume when
the file appears. To prevent timeout, I have added '<httpRuntime
executionTimeout="10000">' to the Web.Config file I also modified the
ASP Script timeout in IIS (Select virtual directory > 'Properties' >
'Configuration' button >'App Options' tab) and set that to 10000
seconds.

1. I have experimented with a FileSystemWatcher:

'-- Suspend processing until file appears
Dim oWatcher As New FileSystemWatcher('c:\myPath\', 'myFile.dat')
Dim oResult As WaitForChangedResult
oResult = oWatcher.WaitForChanged(Created)
'-- Resume processing

.... and this works fine for the first request, but fails for any
subsequent concurrent requests, hanging at the WaitForChanged event
long after the file is created. I have also found that if a large file
is being created the WaitForChanged event is triggered before the file
is finished writing to disk, resulting in (trappable) file access
errors.
2. I though it might then be easier to simply use a Do Loop, checking
until the File.Exists is true, with a Thread.Sleep(1000) for each
iteration:

'-- loop until file appears
Dim iSeconds As Long
Do Until File.Exists("c:\myPath\myFile.dat") = True
iSeconds += 1
Threading.Thread.Sleep(1000) '-- Sleep for 1 second
Loop
'-- Resume processing

.... however, I am finding that after 60-90 seconds, this fails on the
Thread.Sleep(1000) line, with the error message "Thread was being
aborted".

I am also finding that when this error throws to an exception, the
asp.net app appears to hang. In the catch block I have a simple
response.write to return the error message and I have tried adding a
response.end, but it won't die.
So my question is, what is the best way to suspend processing in an
asp.net application (for between 1-15 minutes), while a file is
generated by another process.

Thanks,

Stephen

Nov 18 '05 #2

P: n/a
Instead of suspending process in asp.net why don't u generate a message screen..aspx with message "ur request is processing..." and refresh this page for every 1 min.get status whether file is generated or not...whenever it refreshes...
to get status set value as globalvariable or put in a database....
if status is genarated show normal screen instead of processing page...

"Stephen Miller" wrote:
I have an ASP.Net application that sends a NetworkStream to a .Net
Service, which has a TcpListener listening on a port for the ASP.Net
client. When it receives a request it creates a new thread with the
AddressOf a class that runs a long data intensive process that can
take between 1-15 minutes and results in the creation of a uniquely
named file.

Meanwhile, I want my ASP.Net application to sit and wait until the
file appears at a given location (signalling that the worker thread
has ended) and then resume processing. I have built a .Net Service to
handle this processing because I was finding that IIS was running into
memory problems, when processing multiple requests.

Anyway, my problem is getting the ASP.Net to wait and then resume when
the file appears. To prevent timeout, I have added '<httpRuntime
executionTimeout="10000">' to the Web.Config file I also modified the
ASP Script timeout in IIS (Select virtual directory > 'Properties' >
'Configuration' button >'App Options' tab) and set that to 10000
seconds.

1. I have experimented with a FileSystemWatcher:

'-- Suspend processing until file appears
Dim oWatcher As New FileSystemWatcher('c:\myPath\', 'myFile.dat')
Dim oResult As WaitForChangedResult
oResult = oWatcher.WaitForChanged(Created)
'-- Resume processing

.... and this works fine for the first request, but fails for any
subsequent concurrent requests, hanging at the WaitForChanged event
long after the file is created. I have also found that if a large file
is being created the WaitForChanged event is triggered before the file
is finished writing to disk, resulting in (trappable) file access
errors.
2. I though it might then be easier to simply use a Do Loop, checking
until the File.Exists is true, with a Thread.Sleep(1000) for each
iteration:

'-- loop until file appears
Dim iSeconds As Long
Do Until File.Exists("c:\myPath\myFile.dat") = True
iSeconds += 1
Threading.Thread.Sleep(1000) '-- Sleep for 1 second
Loop
'-- Resume processing

.... however, I am finding that after 60-90 seconds, this fails on the
Thread.Sleep(1000) line, with the error message "Thread was being
aborted".

I am also finding that when this error throws to an exception, the
asp.net app appears to hang. In the catch block I have a simple
response.write to return the error message and I have tried adding a
response.end, but it won't die.
So my question is, what is the best way to suspend processing in an
asp.net application (for between 1-15 minutes), while a file is
generated by another process.

Thanks,

Stephen

Nov 18 '05 #3

P: n/a
I've thought about that, but it doesn't suit what I am trying to do

HARI PRASD BARU <HA***********@discussions.microsoft.com> wrote in message news:<39**********************************@microso ft.com>...
Instead of suspending process in asp.net why don't u generate a message screen..aspx with message "ur request is processing..." and refresh this page for every 1 min.get status whether file is generated or not...whenever it refreshes...
to get status set value as globalvariable or put in a database....
if status is genarated show normal screen instead of processing page...

"Stephen Miller" wrote:
I have an ASP.Net application that sends a NetworkStream to a .Net
Service, which has a TcpListener listening on a port for the ASP.Net
client. When it receives a request it creates a new thread with the
AddressOf a class that runs a long data intensive process that can
take between 1-15 minutes and results in the creation of a uniquely
named file.

Meanwhile, I want my ASP.Net application to sit and wait until the
file appears at a given location (signalling that the worker thread
has ended) and then resume processing. I have built a .Net Service to
handle this processing because I was finding that IIS was running into
memory problems, when processing multiple requests.

Anyway, my problem is getting the ASP.Net to wait and then resume when
the file appears. To prevent timeout, I have added '<httpRuntime
executionTimeout="10000">' to the Web.Config file I also modified the
ASP Script timeout in IIS (Select virtual directory > 'Properties' >
'Configuration' button >'App Options' tab) and set that to 10000
seconds.

1. I have experimented with a FileSystemWatcher:

'-- Suspend processing until file appears
Dim oWatcher As New FileSystemWatcher('c:\myPath\', 'myFile.dat')
Dim oResult As WaitForChangedResult
oResult = oWatcher.WaitForChanged(Created)
'-- Resume processing

.... and this works fine for the first request, but fails for any
subsequent concurrent requests, hanging at the WaitForChanged event
long after the file is created. I have also found that if a large file
is being created the WaitForChanged event is triggered before the file
is finished writing to disk, resulting in (trappable) file access
errors.
2. I though it might then be easier to simply use a Do Loop, checking
until the File.Exists is true, with a Thread.Sleep(1000) for each
iteration:

'-- loop until file appears
Dim iSeconds As Long
Do Until File.Exists("c:\myPath\myFile.dat") = True
iSeconds += 1
Threading.Thread.Sleep(1000) '-- Sleep for 1 second
Loop
'-- Resume processing

.... however, I am finding that after 60-90 seconds, this fails on the
Thread.Sleep(1000) line, with the error message "Thread was being
aborted".

I am also finding that when this error throws to an exception, the
asp.net app appears to hang. In the catch block I have a simple
response.write to return the error message and I have tried adding a
response.end, but it won't die.
So my question is, what is the best way to suspend processing in an
asp.net application (for between 1-15 minutes), while a file is
generated by another process.

Thanks,

Stephen

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.