Witam!
Nadal dręczę tego sapera, a Was przy okazji. Stworzyłem nowy wątek z podaną metodą.
private void ThreadTask()
{
DateTime teraz;
TimeSpan roznica = new TimeSpan();
TextBox czas = new TextBox();
czas.Parent = this.GroupBox1; // tu wywala
czas.Left = 100;
czas.Top = 155;
czas.Width = 100;
czas.Height = 23;
DateTime count = new DateTime();
while (roznica.Minutes < 10)
{
teraz = DateTime.Now;
roznica = teraz - count;
czas.Text = roznica.Minutes.ToString() + ":" + roznica.Seconds.ToString() + ":" + roznica.Milliseconds;
}
}
Jednak pole tekstowe czas było przesłonięte przez GroupBox1. Gry próbuje mu dodać "parent", to wyrzuca
Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.
Widziałem już taki problem podczas szperania w google, ba! Nawet tutaj na forum. Jednak każde utworzenie delegata itp. zakończyło się niepowodzeniem.
Proszę o pomoc!