473,396 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
3 2926
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Elliot M. Rodriguez | last post by:
A few of our customers cannot access one of the pages on our vb.net asp.net site. The problems are limited to only a few people, but these people have the problem regularly. The page in question...
5
by: Alan Silver | last post by:
Hello, I have a page that is supposed to do some checking, and if OK, set a session variable before redirecting to another page. The following code is a simplified version, I have hard-coded the...
4
by: hitendra15 | last post by:
Hi following is the code which sends file to the browser means user can download file, but the code generates error message Thread Being Aborted., will any one put their thoughts protected void...
4
by: R.A.M. | last post by:
Hello, Could you help me plase? I have an ASP.NET page with "Search" button; when button is clicked Search_Click is called; here's the code: protected void Search_Click(object sender, EventArgs...
1
by: R.A.M. | last post by:
Hello, Could you help me plase? I am describing my problem second time because I haven't got a solution. I have an ASP.NET page with "Search" button; when button is clicked Search_Click is...
4
by: Totto | last post by:
Hi, I'm doing a server.transfer from a click event of a button, but an exception is raised with "Thread was being aborted" Anyone know why? Thanks Tor
2
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post by:
I used Response.Redirect("other.aspx") in my application. This will arise the exception "Thread is being aborted". How can i get rid of this exception? BTW, i can not use the...
1
by: active | last post by:
When I run an app outside of the IDE I get the exception Thread was being aborted Does that error mean something to you? Any idea what might be causing it? ++++++++++++++++
5
by: Neil | last post by:
Hi, Long story short, we use "Server.Execute" to grab the output from an ASPX page ... Server.Execute("page.aspx", textWriter); We've noticed that intermittantly, we get a "Thread was being...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.