The call to
ToString()
after
Sname
is completly useless as you already have a
string
.
It does not make much sense to give the focus to a control inside a loop.
Your variables are not properly named according to .NET convention. Variables should start with a lowercase letter.
Your variable name are not descriptive.
Usually, it is better to use
int.TryParse
(
Int32.TryParse Method (System)[
^]) to convert a string to an integer.
It does not make much sense to directly have a delay inside UI thread as the application will stop responding. It would be a good idea to read the documentation:
Task.Delay Method (TimeSpan) (System.Threading.Tasks)[
^]. You should probably use
await
keyword as in the example so that the UI thread won't be blocked.
Also check the version that take an integer as it give some extra information about the use of
await
:
Task.Delay Method (Int32) (System.Threading.Tasks)[
^].
See also that code:
TechNet Wiki[
^]
Some extra links:
Don't deadlock with async and await[
^]
Will it block? Debunking async/await pitfalls - Journey of Code[
^]