Hello again!
I'm trying to visualize a very intensive double for-loop piece of code. The story is that there are a number of job I need to process. Say 200 jobs. For each job, i need to go through a list of workers I have, say 500. There are criteria (address, max distance from job, job type) that shortlist the workers to some extent before the inner for-each worker loop starts.
So I have a total progress (Total number of jobs) and a secondary progress for each primary unit. I need to get the RadProgressManager + RadProgressArea working here. I used a tutorail and some forum help to get the basics up but the behaviour is not what I accepted. The only thing that is visualizing is the time elapsed thing and the rest of the control just remains still. no progress bar movement at all.
Currently, the function is taking around 7 minutes to solve 250 jobs. The function has room for improvement, no doubt, but for now, I just need my user(s) to know something is happening and how far along is it.
Thanks.
Code:
HTML:
Thanks.
I'm trying to visualize a very intensive double for-loop piece of code. The story is that there are a number of job I need to process. Say 200 jobs. For each job, i need to go through a list of workers I have, say 500. There are criteria (address, max distance from job, job type) that shortlist the workers to some extent before the inner for-each worker loop starts.
So I have a total progress (Total number of jobs) and a secondary progress for each primary unit. I need to get the RadProgressManager + RadProgressArea working here. I used a tutorail and some forum help to get the basics up but the behaviour is not what I accepted. The only thing that is visualizing is the time elapsed thing and the rest of the control just remains still. no progress bar movement at all.
Currently, the function is taking around 7 minutes to solve 250 jobs. The function has room for improvement, no doubt, but for now, I just need my user(s) to know something is happening and how far along is it.
Thanks.
Code:
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { if (HasJobsToBook()) { FinalSolution.Rows.Clear(); RetrieveJobsToBookBatchIDs(); long iCount = RetrieveActualJobsAgainstBatchIDs(); PreSortTheJobs(iCount); LabelError.Visible = true; LabelError.Text = String.Format("I have {0} job(s) to process!", iCount); RadProgressAreaGenie.ProgressIndicators &= ~ProgressIndicators.SelectedFilesCount; } } RadProgressAreaGenie.Localization.Uploaded = "Total Progress"; RadProgressAreaGenie.Localization.UploadedFiles = "Progress"; RadProgressAreaGenie.Localization.CurrentFileName = "Job Genie in action!";}private void MatchALocum() { LabelError.Visible = false; LabelError.Text = string.Empty; if (CountOfJobsToBook() < 1) { LabelError.Visible = true; LabelError.Text = "No job(s) to process."; Trace.Warn("Job Genie", "No job(s) to process."); return; } RadProgressContext progress = RadProgressContext.Current; progress.Speed = "N/A"; try { #region Declerations int iCounterControl = 0; int iCounterControlInner = 0; foreach (DataRow Row in TableJobsToBook.Rows) { iCounterControl = iCounterControl + 1; progress.PrimaryTotal = TableJobsToBook.Rows.Count; progress.PrimaryValue = iCounterControl; progress.PrimaryPercent = (iCounterControl / TableJobsToBook.Rows.Count) * 100; if (!Response.IsClientConnected) { //Cancel button was clicked or the browser was closed, so stop processing break; } #region Key Extracted Job Properties #region Availability #region Distance Preperation iCounterControlInner = 0; foreach (long ListOfCandidateLocumID in ListOfCandidateLocumIDs) { iCounterControlInner = iCounterControlInner + 1; progress.SecondaryTotal = ListOfCandidateLocumIDs.Count(); progress.SecondaryValue = iCounterControlInner; progress.SecondaryPercent = (iCounterControlInner / ListOfCandidateLocumIDs.Count()) * 100; progress.CurrentOperationText = "Step " + iCounterControlInner.ToString(); //Massive + Intensive code here... //Stall the current thread for 0.1 seconds System.Threading.Thread.Sleep(100); }//For Loop Candidates progress.TimeEstimated = (TableJobsToBook.Rows.Count - iCounterControl) * 100; //Stall the current thread for 0.1 seconds System.Threading.Thread.Sleep(100); }//For Loop Jobs } catch (Exception ex) { Trace.Warn("Job Genie", "Exception:" + ex.Message); throw new Exception("Error while running Job Genie.", ex); }}HTML:
<telerik:RadProgressManager ID="RadProgressManagerGenie" runat="server" Skin="Office2007" /><telerik:RadProgressArea ID="RadProgressAreaGenie" runat="server" Skin="Office2007" Culture="(Default)" ProgressIndicators="TotalProgressBar, TotalProgress, TotalProgressPercent, FilesCountBar, FilesCount, FilesCountPercent, SelectedFilesCount, CurrentFileName, TimeElapsed, TimeEstimated" Width="100%"> <Localization Uploaded="Uploaded" /></telerik:RadProgressArea>Thanks.