I want to make an infinite method that generates a random number for a "slot machine". I also have to be able to stop it upon click of a button to finalize a number.
The vital code is this:
public async Task Numbers(TextBox textbox, CancellationToken token)
{
Random rnd = new Random();
while (token.IsCancellationRequested == false)
{
textbox.Text = rnd.Next(1, 10).ToString();
await Task.Delay(100);
}
}
public async void Check(TextBox textbox, Button button)
{
CancellationTokenSource cts = new CancellationTokenSource();