c# - How can I show a messagebox or loadingbox while doing a loop? (Code may be blocked and after 25 seconds continue) -
I already have this but it does not work ... I have to check whether a little more than PLC . If it is still high then I need to wait 5 seconds and check it again. Now I am trying to find something so that there are some visual feedback for the user. I want to 'wait ...' in a text box, after waiting for the score to rise for 5 seconds. I tried a lot of things but it does not seem to work. Most of the time this GUI is hanging without updating 25 seconds and then it is continuing ...:
// Check in advance whether the PLC bit, which says that there is still an order active, // is still set if this is the case, we wait a few seconds Var bitorder = main POGet Value (jbmis.IO_GET_INPUT, "Boxman Installed"); Int counter = 1; String loading point = ""; Loadtimer.Tick + = TimerTit; Loadtimer.Interval = (int) TimeSpain Foamseconds (5). Total EmilisCand; Loadtimer.Start (); Loadtimer.Enabled = true; // stopwatch SW = new stopwatch (); While (Bitterar! = 0 & amp; Loadprim Control! = 25) {// Tuda Multithrade #region testcode // MessageBox.Show ("Waiting for the previous order" + loading points); // Context.UserMessageService // .ShowMessage ("Waiting to close the previous order" + // loading points, "waiting"); // sw.Start (); // while (sw.Elapsed & lt; TimeSpan.FromSeconds (25)) // // {(sw.Elapsed.Seconds% 5 == 0) // {// loadpoints = loadingpoints + "." ;; // tbScannedEANPick.Background = Brushes.OrangeRed; // tbScannedEANPick.Text = "Waiting" + loading point; //} //} // sw.Stop (); // loading points = loading points + "."; // tbScannedEANPick.Background = Brushes.OrangeRed; // tbScannedEANPick.Text = "Waiting" + loading point; // tbScannedEANPick.UpdateLayout (); # Ndriania (load timerquare% 5 == 0) {loadingpoints = loadingpoints + "."; "; TbScannedEANPick.Background = Brushes.OrangeRed; TbScannedEANPick.Text =" Waiting "+ Loading Point; TbScannedEANPick.IsReadOnly = True; Bitter = Main.POGate Value (jbmis.IO_GET_INPUT," BoxmanInstandard ");} Counter ++;} / Turn off the timer after / 25 seconds and turn on loadtimer. Stop (); zero timercut (object sender, eventArgse E) {loader factor + = 5;}
I searched half day I am ... Thread Soth, Timer, Stopwatch, ... all the main threads or to use the side thread Thank you in advance!
You need to work on different threads Look in.
Or you can just use multi threading. I advise to use asynchronous programming to work on background and update GUI's text box control.
Comments
Post a Comment