for loop - Why won't the printing message print in my C# code? -


i trying print out message "printing..." txtmessage.text text box before loop runs never print text box before loop runs. idea why?

else             {                 txtmessage.text = "printing...";                 (int = numbercopies; != 0; i--)                 {                     int paper = convert.toint32(lblpaperamount.text);                     paper--;                     if (paper == 480 || paper == 380 || paper == 400 || paper == 200)                     {                         messagebox.show("there paper jam! please remove jam , hit ok button continue!", "important message", messageboxbuttons.ok, messageboxicon.exclamation);                      }                     lblpaperamount.text = convert.tostring(convert.toint32(lblpaperamount.text) - 1);                     lbltoneramount.text = convert.tostring(convert.toint32(lbltoneramount.text) - 1);                     thread.sleep(1000);                 }                 txtmessage.text = "job completed!";             } 

try adding call refresh after setting text. it's possible you're entering loop enough refresh not happen until exit.

else {     txtmessage.text = "printing...";     txtmessage.refresh(); //force control redraw     (int = numbercopies; != 0; i--)     {         int paper = convert.toint32(lblpaperamount.text);         paper--;         if (paper == 480 || paper == 380 || paper == 400 || paper == 200)         {             messagebox.show("there paper jam! please remove jam , hit ok button continue!", "important message", messageboxbuttons.ok, messageboxicon.exclamation);          }         lblpaperamount.text = convert.tostring(convert.toint32(lblpaperamount.text) - 1);         lbltoneramount.text = convert.tostring(convert.toint32(lbltoneramount.text) - 1);         thread.sleep(1000);     }     txtmessage.text = "job completed!"; } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -