c# - Sleep in for loop to create smooth effect -


i'd create loop change shape of form on course of second create smooth effect. using code below, error reading 'then name 'thread' not exist in current context'. can me out?

for (var = 1; > 221; i++ ) {     form1.activeform.height += 1;     application.doevents();     thread.sleep(4.5); } 

it's bad idea sleep in gui thread, inhibits normal event processing code that, e.g., keeps gui painted , keeps gui controls responsive. instead, use system.windows.forms.timer same interval otherwise sleep , work in event handler timer.tick.

edit: noticed code calls application.doevents(), mitigates ui freezing problem has own sets of gotchas.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -