Answer the question
In order to leave comments, you need to log in
How to implement "running" points?
It would be desirable to make the display of waiting of process.
It should look like this: 1) .
2) ..
3) ...
4) .
And so in the cycle.
The question is how to implement this in c#?
This came to mind, but when launched, the form freezes and does not respond:
int i = 0;
int k = 0;
while (i < 1000)
{
if (k == 0)
{
label1.Text = ".";
k = 1;
}
else if (k == 1)
{
label1.Text = "..";
k = 2;
}
else
{
label1.Text = "..";
k = 0;
}
Thread.Sleep(100);
i++;
}
Answer the question
In order to leave comments, you need to log in
If you have this code called on the user interface thread, then there is nothing surprising in this. You are blocking message queue processing and preventing controls from even redrawing themselves.
In "good" applications, it is not worth blocking the UI, you need to transfer the code to a parallel thread, and from there update the controls.
But in extreme cases, you can just periodically let the message queue "piss off" using Application.DoEvents ().
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question