valera456
valera456
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
its now working correctly! thanks
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
so i have to out an int for that?
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
the application does not reflect that for some reason
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
yes it does stop at the breakpoint. and it does get deeper into the actual number set of a textbox.
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
what do i check for exactly? in the locals or?
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
so when does it run?
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
but when i try to do task.Start() it says that its running on promise-style
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
its not showing anything so its not running
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
i did
if (task.Status==TaskStatus.Running)
{
MessageBox.Show("Yes");
}
if (task.Status==TaskStatus.Running)
{
MessageBox.Show("Yes");
}
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
i dont know? lemme see
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
It still does not display any numbers on initial press.
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
i repurposed it to
CancellationTokenSource cts1 = new CancellationTokenSource();
CancellationTokenSource cts2 = new CancellationTokenSource();
CancellationTokenSource cts3 = new CancellationTokenSource();
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)
{
if (button.Text=="Пуск")
{
var task = Task.Run(()=>Numbers(textbox, cts.Token),cts.Token);
button.Text = "Стоп";
}
else if (button.Text=="Стоп")
{
cts.Cancel();
button.Text = "Пуск";
}
if (button1.Text=="Пуск" && button2.Text == "Пуск" && button3.Text == "Пуск")
{
textBox1.Text = Determine(textBox2, textBox3, textBox4);
}
}
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Check(textBox2, button1, cts1);
}

private void button2_Click(object sender, EventArgs e)
{
Check(textBox3, button2, cts2);
}

private void button3_Click(object sender, EventArgs e)
{
Check(textBox4, button3, cts3);
}
CancellationTokenSource cts1 = new CancellationTokenSource();
CancellationTokenSource cts2 = new CancellationTokenSource();
CancellationTokenSource cts3 = new CancellationTokenSource();
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)
{
if (button.Text=="Пуск")
{
var task = Task.Run(()=>Numbers(textbox, cts.Token),cts.Token);
button.Text = "Стоп";
}
else if (button.Text=="Стоп")
{
cts.Cancel();
button.Text = "Пуск";
}
if (button1.Text=="Пуск" && button2.Text == "Пуск" && button3.Text == "Пуск")
{
textBox1.Text = Determine(textBox2, textBox3, textBox4);
}
}
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Check(textBox2, button1, cts1);
}

private void button2_Click(object sender, EventArgs e)
{
Check(textBox3, button2, cts2);
}

private void button3_Click(object sender, EventArgs e)
{
Check(textBox4, button3, cts3);
}
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
what am i supposed to do then
17 replies
CC#
Created by valera456 on 6/19/2023 in #help
❔ What did I do wrong with this task formation?
the function Numbers() doesnt work when a part of task. if i put it as is it works.
17 replies