A small multi threading question.

A small multi threading question.

Old forum URL: forums.lhotka.net/forums/t/1736.aspx


RangerGuy posted on Friday, November 10, 2006

I have a web app that will be processing creditcards. What I would like to do is this. 1) Client enters CC info 2) Client clicks submit 3) submit button is disabled 4) Request is sent to BO layer asynchronously. This could take up to 30secs to process. 5) Update the client without a postback notifing of the status of the processing such as (Sent,Processing,Recieving etc) But we never want the user to wait that long. 5) We would like to say wait for 10seconds for a response if no response or error recieved redirect to the next page. While the BO (ProcessPayment) is still runign on it's own thread waiting for a response . I was thinking of doing this with the new backgroundworker object in my ProcessPayment object.. then I can call this using ajax or an another asynchronous method and pass the processing flags back down to the client from the BO as I recieve them.. Does this make sense or is this completely off the wall for a web app?

ajj3085 replied on Friday, November 10, 2006

If you have a web app and are using ajax (or something similar) there's no need for using background worker in your business layer.  The webserver can already handle multiple requests.

You probably want to send the initial message, get a response that it was recieved ok.  Then ever now and then you send another request to get the status (assuming that you store the current status somewhere you can retreive it).

The backgroundworker component is meant to be used in Windows forms applications.  Although you can use it in your business layer, in this case I don't think you need to.

HTH
Andy

Bayu replied on Friday, November 10, 2006

I agree with Andy that a background worker is not necessary. The asynchronicity can be realized exclusively in your UI in this case, which is a bless. Multi-threading or even just async routines are cumbersome to implement and debug when compared to their synchronous equivalents.

Recently a friend of mine pointed me to jQuery (www.jquery.com), which appears to a be very lean-and-mean yet robust and cross-browser compatible javascript-toolkit to realize asynchronous communication on the background. Unfortunately I haven't had the chance to actually verify all these claims yet, but it sure looks useful.

Regards,
Bayu

RangerGuy replied on Friday, November 10, 2006

Thanks for great tips :)

Copyright (c) Marimer LLC