Forum Discussion

Jerry8989-'s avatar
Jerry8989-
Copper Contributor
Nov 18, 2026

Visual Studio Windows Service to fix ASP.Net website very long process time timing out

Hello,

I have a classic ASP.NET website that allows users to put data variables into a cart and then a new data file with all the data linking is created.  Once the user selects all their data and submits the job the website creates a SAS software program that makes calls to different macros on Linux to create the data file. 

If the amount of selected data is less then 5,000 data variables we run sas.exe on the initial web process and the user can wait for the data files to complete. 

If the selected data is larger than 5,000 then a new thread is created and the sas.exe is called from the new thread and the user will receive an email when the data completes.  The issue that is happening is with jobs with 80K+ data variables that take up to 4 hours of processing.  I assumed the issue was with the session timing out or the application pool timing out or going idle but I updated those settings to larger numbers that would cover the time.  When this happens the thread doesn't know to go back to C# and continue updating the database with the job statistics and end date and time.

I read that using a Windows Service would stop this issue from happening since the service doesn't stop.

  1. Is it true that using a windows service would resolve my issue?
  2. How can I share my code with the Windows Service so it can run the code that is getting lost when it's a large job? 
  3. Can I check if there are x amount of data variables or higher to use the windows service or else continue to use the website process?
  4. Is there a different timeout setting I should add or update?

Software I'm using: Visual Studio 2019 with .Net 4.8.1, Windows Server 2022 Standard, IIS, SAS 9.4, Oracle 19c.

Thank you

2 Replies

  • davidbro8's avatar
    davidbro8
    Brass Contributor

    Your best solution is to move jobs exceeding 5,000 variables to a Windows Service, keeping shorter jobs within ASP.NET.

     

    Recommended approach:

     

    1. Create a reusable .NET Framework 4.8.1 Class Library containing your SAS execution and Oracle update logic.

    2. Create a Windows Service that references this library.

    3. Store long-running jobs in an Oracle job queue.

    4. Let the service process pending jobs independently of IIS.

    5. Update job status, completion time, and email notifications when processing finishes.

    6. Implement error handling and recovery if the server restarts.

     

    Important: Don't use background threads inside ASP.NET for four-hour jobs. A database-backed queue ensures jobs aren't lost during IIS recycling or application restarts.

     

    This approach requires minimal changes to your existing SAS code and provides much better reliability.

    • Jerry8989-'s avatar
      Jerry8989-
      Copper Contributor

      This is great, I already have most of the SAS execution code in a class library.  I will add the rest to make it complete.

      Thank you Mark for your complete breakdown of the steps I should take.