Re: Updating Web Form Control From Thread
From: Scott Allen (bitmask_at_[nospam)
Date: 11/03/04
- Next message: Kevin Spencer: "Re: Updating Web Form Control From Thread"
- Previous message: Mat: "Public Functions in Global.asax?"
- In reply to: Jervin Justin: "Re: Updating Web Form Control From Thread"
- Next in thread: Kevin Spencer: "Re: Updating Web Form Control From Thread"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 03 Nov 2004 10:42:23 -0500
Hi Jervin:
The problem with using a seperate thread is that you still need to
block the response until that second thread returns data. From the
code here it looks as if the second thread starts and then the page
processing continues as normal, meaning Page_Load finishes, the
controls will render, and the HTML is sent to the client. Once all
that happens it is too late to make any changes to the controls, the
response has completed and nothing else will be sent to the browser.
My suggestion is to try without using a second thread - it won't buy
anything in terms of of responsiveness.
This article also has some ideas if you want to send a response to the
browser client immediately and then do the web service work while the
client (browser) polls:
How To: Submit and Poll for Long-Running Tasks
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenethowto08.asp
-- Scott http://www.OdeToCode.com/blogs/scott/ On 3 Nov 2004 07:08:39 -0800, jervinjustin@yahoo.com (Jervin Justin) wrote: >Well let me try to generalize. > >I have a web application (web Form)running on a server (ServerA), >which connects to a web service (running either on the same server or >different, no matter). When a user opens the web app, and clicks a >button, the app sends info to the service. The service now has >multiple updates which it has to send back to the web application > >Is there anyway to update the text (not recreate a new control)in one >of my textboxes on the webform based on information that comes to the >web application as soon as it gets it? > >Remember since I am polling, I get the information on a separate >thread. If there is any better way, I am oopen so suggestions. > >Code snippet follows > >thanks again. >Jervin > >//Part of Web Application (WebForm) >//In Page_Load >if (!isPostBack) >{ > svc = new webService (); > Thread poll = new Thread (new ThreadStart (update)); > poll.Start(); >} > >//Thread: >public void update () >{ > while (true) > { > string str = svc.waitForReply (); //The service automatically sends >updates from this method > textBoxUpdate.Text = str; //Does not update since in separate >thread > } >}
- Next message: Kevin Spencer: "Re: Updating Web Form Control From Thread"
- Previous message: Mat: "Public Functions in Global.asax?"
- In reply to: Jervin Justin: "Re: Updating Web Form Control From Thread"
- Next in thread: Kevin Spencer: "Re: Updating Web Form Control From Thread"
- Messages sorted by: [ date ] [ thread ]