niros Posted July 6, 2004 Posted July 6, 2004 Hi, I need an advice how to make something work: I am running this program via an aspx page. the user is giving me some data via the form and then when he press 'run' button it create an instant of class "serverMaintain" and start running it. I wanted to know how I can I give the user a "processing" status, and the "done". first I made the from inside a <div> and I made anther div for the status, then I run the "serverMaintain" as a thread and gave it in the constructor a ref to both the divs. then when the working procedure started I changed the div according to processing status and then at the end to done status. the only problem is when I tried to worked the divs by reference from the "serverMaintain" I got serialization exception. I guess there are better ways to do that. ill be happy to know about them or about a way to fix mine. is there a way that I can run a "server side" script from my thread? that will solve the problem. Thanks Quote
bri189a Posted July 6, 2004 Posted July 6, 2004 Hi, I need an advice how to make something work: I am running this program via an aspx page. the user is giving me some data via the form and then when he press 'run' button it create an instant of class "serverMaintain" and start running it. I wanted to know how I can I give the user a "processing" status, and the "done". first I made the from inside a <div> and I made anther div for the status, then I run the "serverMaintain" as a thread and gave it in the constructor a ref to both the divs. then when the working procedure started I changed the div according to processing status and then at the end to done status. the only problem is when I tried to worked the divs by reference from the "serverMaintain" I got serialization exception. I guess there are better ways to do that. ill be happy to know about them or about a way to fix mine. is there a way that I can run a "server side" script from my thread? that will solve the problem. Thanks Since the internet is iheritantly static I would do it one of two ways if it were me, I'm sure someone has a better way; I don't know it all. 1. Don't display the page back until the process completes; although if the process can take a while this might cause a time out, but if it's a 10 - 20 second process I think it would be safe. 2. If it takes awhile: a. If the max this thing will be running is one at a time you can check your current processes and have the page automatically post back every 15 seconds or so and see if that process is still running. b. make the other program write a small file, or talk to a database, the web application checks that location and when the other program deletes the files, or writes in the file it is done the web app knows it's done. Web pages are inheritantly static. This means that you are not going to be able to go to a page and 30 seconds later go back to the server and expect to find values from a previous action... they won't be there; thus null reference. Quote
niros Posted July 7, 2004 Author Posted July 7, 2004 Hi, Thanks for the help, but how can I make suggestion 'a' to work?? If I start a thread and then the page reloads, I can still approach to that thread and check it status?? can I do that via web (I mean save a reference to a thread from post to post)? Thanks Quote
bri189a Posted July 7, 2004 Posted July 7, 2004 Hi, Thanks for the help, but how can I make suggestion 'a' to work?? If I start a thread and then the page reloads, I can still approach to that thread and check it status?? can I do that via web (I mean save a reference to a thread from post to post)? Thanks If in your routine your join the new thread your forced to wait until it completes to continue the procedure: protected void SomeWebPageProcedure() { Thread t = new Thread(new ThreadStart(whatever)); t.Start(); t.Join(); //The below won't execute until the above thread is complete SomeOtherProcedure(); } At least that's how it works in application programs. Maybe web programs are differant, but I seriously doubt it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.