Witam!
Mam taki oto program, chcę w klasie zadeklarowanej zmienić Text któregoś z labeli, jednak mam taki problem. Program w klasie nie widzi tych kontrolek (labeli), mam je ułożone na formie graficznie. Prosiłbym o podanie ja kto zrobić, aby działało, szukałem po internecie, jednak nic nie chciało mi zadziałać, bądź nie rozumiałem o co chodzi.
Oto kod:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace kjh
{
public class MyThreadClass
{
public MyThreadClass()
{
}
public void Run()
{
label14.Text = "tekst";
label15.Text = "tekst";
Thread.Sleep(500);
label16.Text = "tekst";
}
}
public partial class kjh : Form
{
public kjh()
{
InitializeComponent();
MyThreadClass oMyThreadClass = new MyThreadClass();
Thread oThread = new Thread(new ThreadStart(oMyThreadClass.Run));
oThread.Start();
label13.Text = "Oczekiwanie na zakończenie wątku...";
oThread.Join();
}
}
}