c# - Loading gif image visible while the execution process runs -
i using window app , c#.. have picture invisible @ start of app.. when button clicked, picture box has shown..
i use coding picture box not visible
private void btnsearch_click(object sender, eventargs e) { if (cmbproject.text == "---select---") { messagebox.show("please select project name"); return; } else { picturebox1.visible = true; picturebox1.bringtofront(); picturebox1.show(); fillreport(); thread.sleep(5000); picturebox1.visible = false; } }
don't use sleep
- blocks thread, means no windows messages processed, , form won't repainted.
instead, use timer
hide image after 5 seconds.
add timer form, , change code this:
picturebox1.visible = true; fillreport(); timer1.interval = 5000; timer1.start();
and in timer event:
private void timer1_tick(object sender, eventargs e) { picturebox1.visible = false; timer1.stop(); }
now image should visible 5 seconds.
however, form still not repaint while fillreport
executing. if need image visible @ point, suggest using backgroundworker
execute fillreport
doesn't block ui thread. can hide image in runworkercompleted
event.
Comments
Post a Comment