tag:blogger.com,1999:blog-5602263760491785758.post5297979315662539693..comments2023-06-28T01:39:03.668-07:00Comments on DevArchive.net Blog: Displaying Progress Bar for Long-Running Processes on Server using ASP.NET AJAXKirill Chilingarashvilihttp://www.blogger.com/profile/09906215698720468631noreply@blogger.comBlogger33125tag:blogger.com,1999:blog-5602263760491785758.post-55402714342111410692013-04-12T11:00:55.060-07:002013-04-12T11:00:55.060-07:00Hi,
This is Ravi,
Provided code was very nice. ...Hi,<br /><br />This is Ravi, <br /><br />Provided code was very nice. But it is not working with server side processing. when am calling this script for showing the progress for server side processing, i am getting delay in progress. Could you please help me in how to handle this scenario?<br /><br />Thanks,<br />RaviAnonymoushttps://www.blogger.com/profile/03104988269485380010noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-14337858940897817282011-04-20T13:58:57.253-07:002011-04-20T13:58:57.253-07:00Thank you so much it really helped meThank you so much it really helped meAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-15395023953006331122011-04-12T11:54:13.661-07:002011-04-12T11:54:13.661-07:00Bob, I wish you the best of luck. You have taken...Bob, I wish you the best of luck. You have taken this much farther than I did. I basically just had to make some modifications to get it to display properly with my existing CSS. I didn't pursue the issues that you have (although I certainly will use them if you ever post them!). Because it wasn't critical to the operation I let it slide and used the asp:UpdateProgress instead. Thanks for your efforts.Unknownhttps://www.blogger.com/profile/09082440047202581722noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-30655661389020158852011-03-18T14:24:17.239-07:002011-03-18T14:24:17.239-07:00I managed to get one of my issues working - I can ...I managed to get one of my issues working - I can now start the web traffic only when the "Start" button is pressed, and stop it automatically when all processes are completed. But I am stuck with a threading issue (and I have never written any threading code).<br /><br />In StartProcessing, just before the while loop, I need to call a method in my code that will run until it completes, posting status updates to public variables in this class. This needs to run as a separate thread. Within the while loop, I want to check the public variables that record status towards completion. This will allow me to avoid having to break the work up into 100 small chunks.<br /><br />I can see that StartProcessing is already in a new thread, but I need to launch yet another thread in order to make this work. <br /><br />Ultimately, I want to be able to identify the method I want to launch and the status checking methods as declarations way up in Default.aspx and have the code fire these events properly, but I am not at all clear how to pull this off. <br /><br />Any comments, advice and help appreciated. <br /><br />When I am done with all of this, I plan to have it build as a user control that I can use anywhere and I will be glad to share what I come up with, if I can ever get there.<br /><br />Thanks,<br /><br />Bob JonesBobhttps://www.blogger.com/profile/11819525234262821594noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-76013069581121356152011-03-17T16:14:28.735-07:002011-03-17T16:14:28.735-07:00My second question is, how do I disable the event ...My second question is, how do I disable the event posting when I am not processing a task. The events every .5-5 seconds serve no purpose if a job is not started, so I would like to be able to turn them off and on myself... but I don't yet see how.Bobhttps://www.blogger.com/profile/11819525234262821594noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-29031606581174472852011-03-17T16:12:06.447-07:002011-03-17T16:12:06.447-07:00I have spent all day puzzling through this code an...I have spent all day puzzling through this code and trying to integrate it with my own. It appears to be both dazzling and incomplete, and leads me to several questions that I will ask as individual posts. <br /><br />First, I need to have multiple variants of the StartProcessing method. How do I accomplish this? I cannot yet figure out how, especially since this method is part of the ProcessStatuses class. <br /><br />One thought would be to have three points in this code that raised events in my own: <br /><br />1) Initialize event<br />2) Main loop event<br />3) Completion event<br /><br />and possibly a fourth: Cancellation event (invoked when ExitRequested).<br /><br />Can you comment on this and possibly give some examples of how to implement multiple completely different versions of StartProcessing that are outside your ProcessStatuses class?<br /><br />Thanks!Bobhttps://www.blogger.com/profile/11819525234262821594noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-14700331410617047972010-08-03T05:16:27.395-07:002010-08-03T05:16:27.395-07:00This sample stopped working when I changed session...This sample stopped working when I changed sessionState mode to "StateServer". Do we have any workaround?<br /><br />ThanksNaveennoreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-11274617755020401242010-04-30T12:19:52.254-07:002010-04-30T12:19:52.254-07:00Kirill,
I was so appreciative that I found this...Kirill,<br /> I was so appreciative that I found this I felt compelled to acknowledge your work. Please visit twsdb.com and select the first menu item on the left-hand side of the home page.<br />Thanks again,<br />MarkUnknownhttps://www.blogger.com/profile/09082440047202581722noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-82056254871781147232010-04-29T12:32:36.990-07:002010-04-29T12:32:36.990-07:00Kirill,
Thanks for your feedback. I finally got i...Kirill,<br />Thanks for your feedback. I finally got it (although I haven't published the working version yet.) I can't tell you how much I appreciate your excellent coding. I spent an entire weekend searching for progress bars and every one I found had some deficiency. Yours seems to be perfect! That was a very nice touch where you sleep the process for a random amount of time from 0.1 to 0.5 seconds to simulate a non-linear process. Very cool. I'm sure I will have more questions when I get to using "real" long-running processes, but everything is working so far. Thanks again for supplying this and thanks for your support.<br />Regards,<br /> MarkUnknownhttps://www.blogger.com/profile/09082440047202581722noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-16125515051845039632010-04-28T22:35:49.862-07:002010-04-28T22:35:49.862-07:00Hi Mark,
This is simple to explain and expected t...Hi Mark,<br /><br />This is simple to explain and expected that if you add X sign after percent in css, the widths of div will not be correct again. This requires knowledge of CSS and HTML, I really have no better explanation than this.<br /><br />Regards,<br />KirillKirill Chilingarashvilihttps://www.blogger.com/profile/09906215698720468631noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-50291297867076192562010-04-28T00:20:59.800-07:002010-04-28T00:20:59.800-07:00Kirill,
I was hoping my web site might pique yo...Kirill,<br /> I was hoping my web site might pique your interest. I first downloaded your code and tested it thoroughly to ensure it worked, which it did perfectly. I then implemented the same code into my website and encountered one problem. Please visit www.twsdb.com and select "test progress bar" from the top of the left-hand menu. You will see a page that should be quite familiar. It illustrates the problem I am having. The status increments properly and the bar then changes to green properly. However, it is immediately filled all the way to 100%. I don't think I have the ability to figure out why it is doing this and was really hoping you could. I do have some more information that will probably tell you what is happening. I changed the inner div to a hard-coded 50% and I experienced the same result. I also was able to duplicate this problem in your working example merely by changing the inner div slightly (I added an X after the percent sign.) So the problem must be related to this inner div. Can you please help? I really want to use this. It is a fantastic bit of coding! Thanks, MarkUnknownhttps://www.blogger.com/profile/09082440047202581722noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-27790208689065762272010-04-26T06:15:00.476-07:002010-04-26T06:15:00.476-07:00Once again, this is absolutely fantastic! I will ...Once again, this is absolutely fantastic! I will learn quite a bit from it. I decided to go ahead and publish so you can see the problem I am experiencing. I believe I have implemented it exactly as your code. The progress bar fills immediately, even though you can see the status is not 100%. It even changes to green properly. Please visit www.twsdb.com and select "test progress bar" from the top of the left hand menu. Can anybody help? Please? I really want to use this. Thanks, MarkUnknownhttps://www.blogger.com/profile/09082440047202581722noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-1943814469114156712010-04-07T23:19:22.279-07:002010-04-07T23:19:22.279-07:00Hi Ashwin,
Actually this sample just shows the id...Hi Ashwin,<br /><br />Actually this sample just shows the idea of synchronising data between threads.<br /><br />You can provide "Loading..." description instead of updating percentage if you want.<br /><br />Regards,<br />KirillKirill Chilingarashvilihttps://www.blogger.com/profile/09906215698720468631noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-86381292708507297792010-04-07T23:12:30.482-07:002010-04-07T23:12:30.482-07:00I Have a functionality in which id not have the es...I Have a functionality in which id not have the estimate for DB Operation Running time and its a single Call for database .in this case How can i Update the progress bar percentage.Ashwin Deshpandehttps://www.blogger.com/profile/00654376061115245934noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-73953192348596419302010-01-31T22:06:53.234-08:002010-01-31T22:06:53.234-08:00hi Kirill,
Its really great article.
I m using t...hi Kirill, <br />Its really great article. <br />I m using this approch to generate so many reports. <br />I want to know one thing. I have used MyProcess() method instead of StartProcessing(). I want to pass some variables which need to be use in report generation process. How can i pass those variables? Please suggest.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-83626290125907207642009-11-19T13:59:29.567-08:002009-11-19T13:59:29.567-08:00I’d weakness to tattle-tale that too!I’d weakness to tattle-tale that too!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-62535988639469368422008-11-25T02:17:00.000-08:002008-11-25T02:17:00.000-08:00Rob,You are welcome,I am glad sample is useful for...Rob,<BR/>You are welcome,<BR/>I am glad sample is useful for you.<BR/><BR/>Thanks,<BR/>KirillKirill Chilingarashvilihttps://www.blogger.com/profile/09906215698720468631noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-2033866949337746952008-11-25T01:56:00.000-08:002008-11-25T01:56:00.000-08:00Hi Kirill,Really Great !.. Thanks.. now its workin...Hi Kirill,<BR/><BR/>Really Great !.. Thanks.. now its working fine. Actually i'm configuring multiple number of process using your progressbar.. Its really working great. Thanks Again<BR/>I'm Rob from india<BR/>Thanks<BR/>RobAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-69050789971924648222008-11-24T23:21:00.000-08:002008-11-24T23:21:00.000-08:00Rob,You have to modify ProcessStatus class by addi...Rob,<BR/><BR/>You have to modify ProcessStatus class by adding the following property:<BR/>-------------<BR/>private bool m_ExitRequested = false;<BR/><BR/>public bool ExitRequested<BR/>{<BR/> get { return m_ExitRequested; }<BR/> set { m_ExitRequested = value; }<BR/>}<BR/>----------------<BR/><BR/>Then you can analyze that property inside threads and decide is the thread in a crytical section or not - and exit the thread or continue untill safe point is reached. For example you can modify the thread code (StartProcessing method in ProcessStatuses class) the following way:<BR/>--------------------<BR/>public static void StartProcessing(object data)<BR/>{<BR/> ProcessStatus process = (ProcessStatus)((object[])data)[0];<BR/> while (process.Status < 100)<BR/> {<BR/> if (process.ExitRequested)<BR/> {<BR/> ArrayList.Synchronized((ArrayList)((object[])data)[1]).Remove(process);<BR/> return;<BR/> }<BR/> process.IncrementStatus();<BR/> Random rnd = new Random(DateTime.Now.GetHashCode());<BR/> Thread.Sleep(((int)(rnd.NextDouble()*40)+10) * 10);<BR/> }<BR/> Thread.Sleep(2000);<BR/> ArrayList.Synchronized((ArrayList)((object[])data)[1]).Remove(process);<BR/>}<BR/>--------------------<BR/><BR/>Finally you can request exit of threads in the code requesting start of new threads (LaunchNewProcess method in Command class), by modifying it the following way:<BR/>-------------------------<BR/>public object LaunchNewProcess(object data)<BR/>{<BR/> ProcessStatus newProcess =<BR/> new ProcessStatus(<BR/> String.Format(<BR/> "{0}, started:{1}", <BR/> data, DateTime.Now.ToString("HH:m:ss")<BR/> )<BR/> );<BR/><BR/> ArrayList allProcesses = ProcessStatuses.Get();<BR/> foreach (ProcessStatus status in ArrayList.Synchronized(allProcesses))<BR/> {<BR/> status.ExitRequested = true;<BR/> }<BR/> ArrayList.Synchronized(allProcesses).Clear();<BR/> ArrayList.Synchronized(allProcesses).Add(newProcess);<BR/><BR/> ThreadPool.QueueUserWorkItem(<BR/> new WaitCallback(ProcessStatuses.StartProcessing),<BR/> new object[] {newProcess, allProcesses}<BR/> );<BR/><BR/><BR/> return null;<BR/>}<BR/>--------------------------<BR/><BR/>Regards,<BR/>KirillKirill Chilingarashvilihttps://www.blogger.com/profile/09906215698720468631noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-17337205101432376392008-11-24T23:06:00.000-08:002008-11-24T23:06:00.000-08:00I just want to clear the session. If the user pres...I just want to clear the session. If the user press second time<BR/><BR/>Thanks<BR/>RobAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-46060851030445560922008-11-24T22:06:00.000-08:002008-11-24T22:06:00.000-08:00Hi Rob,What exactly do you want to do - just remov...Hi Rob,<BR/>What exactly do you want to do - just remove visualization on client, or stop the process on the server as well ?<BR/><BR/>KirillKirill Chilingarashvilihttps://www.blogger.com/profile/09906215698720468631noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-56959506727509353412008-11-24T21:54:00.000-08:002008-11-24T21:54:00.000-08:00Hi Krill, As per your code now for each click one ...Hi Krill,<BR/><BR/> As per your code now for each click one progress bar will come. I just want to modify it like. for the second click first progress bar need to be cleared and the new one should come. Could you please help me on this<BR/><BR/>Thanks<BR/>RobAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-12320807414252943642008-11-24T06:21:00.000-08:002008-11-24T06:21:00.000-08:00HiI Integrated your progress bar code with my appl...Hi<BR/><BR/>I Integrated your progress bar code with my application..But same progress bar is coming again if i'm doing the next process after one is completed. So i just want to know if any way to refresh or remove all the process bar.<BR/><BR/>Thanks<BR/>RobAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-45567887220451281472008-11-18T01:24:00.000-08:002008-11-18T01:24:00.000-08:00Hi,The sample works in Firefox and IE just fine, h...Hi,<BR/>The sample works in Firefox and IE just fine, here is a live example:<BR/>http://www.devarchive.net/displaying_progress_bar_for_long_running_processes.aspxKirill Chilingarashvilihttps://www.blogger.com/profile/09906215698720468631noreply@blogger.comtag:blogger.com,1999:blog-5602263760491785758.post-53027297267837455352008-11-18T01:18:00.000-08:002008-11-18T01:18:00.000-08:00Hi KrillGreat article.. But i have a query this pr...Hi Krill<BR/><BR/>Great article.. But i have a query this progress bar is not working fine with Mozilla Firefox browser . Could you please send back to me if any solution for the same. Appreciate your quick <BR/>responses<BR/><BR/>Thanks<BR/>SarathAnonymousnoreply@blogger.com