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

Discussion in 'ASP .Net' started by Stephen Miller, Jul 1, 2004.

  1. 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
    Stephen Miller, Jul 1, 2004
    #1
    1. Advertising

  2. 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
    >
    =?Utf-8?B?SEFSSSBQUkFTRCBCQVJV?=, Jul 1, 2004
    #2
    1. Advertising

  3. 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
    >
    =?Utf-8?B?SEFSSSBQUkFTRCBCQVJV?=, Jul 1, 2004
    #3
  4. I've thought about that, but it doesn't suit what I am trying to do

    HARI PRASD BARU <> wrote in message news:<>...
    > 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
    > >
    Stephen Miller, Jul 2, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Elliot M. Rodriguez
    Replies:
    1
    Views:
    2,917
    Elliot M. Rodriguez
    Jan 22, 2004
  2. =?Utf-8?B?VGF5bw==?=

    Error: Thread was being aborted.

    =?Utf-8?B?VGF5bw==?=, May 30, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,527
    =?Utf-8?B?UnVpIEFpcmVzIFtQVF0=?=
    Aug 9, 2004
  3. Johanna
    Replies:
    0
    Views:
    593
    Johanna
    Oct 13, 2004
  4. =?Utf-8?B?Sm9oYW5uYQ==?=
    Replies:
    3
    Views:
    1,942
    =?Utf-8?B?Sm9oYW5uYQ==?=
    Oct 15, 2004
  5. Gonzalo Moreno
    Replies:
    2
    Views:
    12,375
Loading...

Share This Page