winforms - C# Slow down random number GUI display -


i have application generates random numbers 20 seconds , shows random number on fly in label in screen.

i want show numbers in same label slow down display of numbers 5 seconds before stoping process, display of number should smoothly slow down more , more until stops in final number. raffle.

any clue?

i can start telling not to. not use thread.sleep -- doing "worst practice" , make ui unresponsive.

if use thread.sleep on second thread, mcl suggests, won't freeze ui burning extremely expensive thread little work.

if using c# 4 or earlier create timer set tick, say, 4 times second. handle tick event, , if enough time has passed since last tick event, change label. or, change interval of timer each time ticks.

if using c# 5, can use await task.delay(x):

async void animate() {     int delay = 5;     for(int = 1; < 10; ++i)     {        updatelabel();        await task.delay(delay);        delay = delay * 2;     } } 

so start 5ms delay, 10, 20...


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -