locked
Suitable application architecture RRS feed

  • Question

  • User56171539 posted

    Hi there,

    My problem is something like this... I have a web page with a button and a textarea. When user clicks the button, it causes async postback of the page. On server side the event handler calls a function to process multiple tasks one after the other. I need to periodically display the information about which task is being processed and it's status in the textarea. Can anyone suggest suitable architecture to implement this in asp.net?

    Thanks in advance,

    Sats

    Wednesday, March 10, 2010 5:15 PM

Answers

  • User-1878433365 posted

    Hello Sats,

    Here's what I would probably do in your situation. It may make some sense to you.

    My aspx page will use javascript (ajax) to invoke a web service or another aspx page that will trigger the long running process start. And it will return immediately. Later, you can have a timer in javascript to invoke another web service to request process progress and report that in your text area (dhtml).

    The long running process is the key. It can be implemented using a thread running on your web application space and it should be reporting progress in a database or some external place where the status reporting web service will look to inform the end user.

    I have implemented something like this using System.Threading.Thread and it is very stable.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 10, 2010 7:02 PM
  • User56171539 posted

    Hi Alfredo,

    Thanks for your response. Honestly speaking I figured out the architecture before I read your response; however my architecture closely matches yours. The way I am doing it is... My web page will start a thread to call a web service which will in turn process those tasks. The web service will update an application variable with current status. The page will return after starting the thread. It will use a timer to do frequent async postbacks and to update the status on the screen. 

    Thanks,

    Sats  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 11, 2010 11:34 AM

All replies

  • User-1878433365 posted

    Hello Sats,

    Here's what I would probably do in your situation. It may make some sense to you.

    My aspx page will use javascript (ajax) to invoke a web service or another aspx page that will trigger the long running process start. And it will return immediately. Later, you can have a timer in javascript to invoke another web service to request process progress and report that in your text area (dhtml).

    The long running process is the key. It can be implemented using a thread running on your web application space and it should be reporting progress in a database or some external place where the status reporting web service will look to inform the end user.

    I have implemented something like this using System.Threading.Thread and it is very stable.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 10, 2010 7:02 PM
  • User-967169866 posted

    I wouldn't be keen on building things with System.Threading.Thread that would be called from a web page every click.  That's grounds for some serious scalability issues along with many other problems.

    Use AJAX to query the server if you want to keep your current architecture, and use the thread pool to process the requests.  

    Thursday, March 11, 2010 5:19 AM
  • User56171539 posted

    Hi Alfredo,

    Thanks for your response. Honestly speaking I figured out the architecture before I read your response; however my architecture closely matches yours. The way I am doing it is... My web page will start a thread to call a web service which will in turn process those tasks. The web service will update an application variable with current status. The page will return after starting the thread. It will use a timer to do frequent async postbacks and to update the status on the screen. 

    Thanks,

    Sats  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 11, 2010 11:34 AM
  • User56171539 posted

    Hi KraGiE,

    Thanks for your response. I am not too much concerned about starting a new thread on every button click because the requirement is that there should be only one process (thread) running at a time. I am considering using mutex object to decide whether to allow a new thread to start.

    Thanks,

    Sats

    Thursday, March 11, 2010 11:35 AM
  • User56171539 posted

    A better way than using application object is as following:
    Define a private variable (status) in the WebService class. Update the variable with appropriate status values. Declare a webmethod e.g.
    [WebMethod]|
    public static int GetStatus() return status;}
    Use this webmethod to get the status of execution when needed.

    Thanks,
    Sats.

     

    Monday, March 15, 2010 2:21 PM