private void Pozdrav_Click(object sender, EventArgs e)
{
var worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerAsync();
}
void worker_DoWork(object sender, DoWorkEventArgs e)
{
AnotherThread();
}
private void AnotherThread()
{
int a = Convert.ToInt32(numericUpDown2.Value);
a = a * 1000;
for (int z = 0; z < 5 && a != 0; z++)
{
DateTime start = DateTime.Now;
string s = "Ahoj";
TimeSpan i = DateTime.Now - start;
if (this.InvokeRequired)
{
this.BeginInvoke(new Action(() => this.printValues("Ahoj")));
}
Thread.Sleep(a);
}
}
private void printValues(string values)
{
Vypis3.Text += values + "\r\n";
}