Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Threading UI for wait dialog
    primarykey
    data
    text
    <p>Ok. I have looked around some tried to thread my UI to make this work.</p> <p>I have an application for reporting information. How this work is that I a user control that can be repeated in a scrollable area. so If there are 10 reports to load for a day, it will load this control 20 times in the scrollable area.</p> <p>What I would like is to make a "Please wait" dialog while loading theese controls. But there seems to be a problem to thread UI as a progressbar in Marquee mode wont animate while drawing these controls that should lie in the scrollable area behind.</p> <p>Have tried to generate the controls in a backgroundworker but that wont solve the problem when it comes to the progressbar.</p> <p>Any ideas or tips when it come to threading UI drawing? As I suppose this is what it is. progressbar while drawing other controls.</p> <p>EDIT: I tried show this "Please wait" dialog as both <code>Show();</code> and <code>ShowDialog();</code>. ShowDialog() works but only becouse it pauses the rest of the applications as it waits for an answer.</p> <p>Here is the peace of code generating the controls. this is not the threaded version for background. but the only diffrence is where the "pleaseWait" dialog is placed in the code.</p> <pre><code> /// &lt;summary&gt; /// Generates assignemts after date /// &lt;/summary&gt; /// &lt;param name="date"&gt;Date for selection of what to show&lt;/param&gt; /// &lt;param name="currentWeek"&gt;Week to show&lt;/param&gt; /// &lt;param name="igonerWeekCheck"&gt;Ignor week check, used for startup&lt;/param&gt; private void GenerateAssigmentsAfterDate(DateTime date, int currentWeek, bool igonerWeekCheck) { //refresh UI before generating contens tabPage1.Refresh(); panelScroller.Refresh(); splitContainer1.Refresh(); //freezes UI while loading SuspendDrawing(splitContainer1); panelScroller.SuspendLayout(); if (CurrentTMEngine.LatestWeekNumber != GetWeekNumber(date) || igonerWeekCheck == true) { if (igonerWeekCheck == false) { pleaseWait = PleaseWaitDialog(); pleaseWait.StartPosition = FormStartPosition.CenterParent; pleaseWait.Show(); pleaseWait.Update(); } //should remove current controls from memory int ctrlCount = panelScroller.Controls.Count; for (int i = 0; i &lt; ctrlCount; i++) { panelScroller.Controls[0].Dispose(); } panelScroller.Refresh(); assignmentList.Clear(); assignmentList = null; assignmentList = new List&lt;messageCtrl&gt;(); int rowCountCtrl = 0; foreach (DataRow row in CurrentTMEngine.TMassignmentsTable.Rows) { if (currentWeek == GetWeekNumber(Convert.ToDateTime(row[new TableText().TimeStart]).Date)) { messageCtrl repCtrl = new messageCtrl(rowCountCtrl, Convert.ToInt32(row[new TableText().ID]), Convert.ToDateTime(row[new TableText().TimeStart]), Convert.ToDateTime(row[new TableText().TimeEnd]), panelScroller.Controls, CurrentTMEngine.TMassignmentsTable, row, CurrentTMEngine); assignmentList.Add(repCtrl);//collection to be avalie for show rowCountCtrl++; } } foreach (messageCtrl assign in assignmentList) { if (currentWeek == GetWeekNumber(assign.StartTime.Date)) { if (assign.StartTime.Date == date) { assign.Enabled = true; assign.Height = 142; assign.tableLayoutPanel2.BackColor = System.Drawing.SystemColors.ControlLightLight; } else { assign.Enabled = false; assign.Height = 5; assign.tableLayoutPanel2.BackColor = System.Drawing.SystemColors.ControlDark; } panelScroller.Controls.Add(assign); //ands control } } // SetSizeMessageCtrlByDate(date, currentWeek); pleaseWait.Close(); pleaseWait.Dispose(); } else { SetSizeMessageCtrlByDate(date, currentWeek); } CurrentTMEngine.LatestWeekNumber = GetWeekNumber(date); //unfrezzing UI panelScroller.ResumeLayout(); ResumeDrawing(splitContainer1); } #endregion </code></pre> <p>EIDT 2: Seems to be related to the rendering/drawing of the UI components. I can see this as I expand this scrollable area for the controllers so they all fit. The application freezes until the UI has been redrawn to be with out scrollbar. And vise versa for making it smaller for scroll. This seems to be the type of freeze that occurs while loading the controls. So I guess unless there is a way to have multiple UI threads it might be hard to find a solution for this as it is located in the same application and this applications UI thread. </p> <p>Solution for the problem right now is a "Please wait" dialog without a animated Marquee scrollbar.</p> <p>Will check in to if there is a way to create a separate application for this to fill this purse as that seems to be the only solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload