C# Thread Basic Please correct this (Beginner)
C# Thread Basic Please correct this (Beginner)
(OP)
This does not get reflected in the Form.
I want somebody to simply correct this.
I want somebody to simply correct this.
CODE --> C#
using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { private Timer Timer1; private System.Threading.Thread thr; public Form1() { InitializeComponent(); Thread1(); } private void Thread1() { thr = new System.Threading.Thread(new System.Threading.ThreadStart(threadmethod1)); thr.Start(); } private void threadmethod1() { Timer1 = new Timer(); Timer1.Interval = 200; Timer1.Tick += new EventHandler(Timer1_Tick); Timer1.Enabled = true; Timer1.Start(); } private void Timer1_Tick(object sender, EventArgs e) { DateTime dt = new DateTime(); this.label1.Text = dt.ToLongTimeString(); } } }
RE: C# Thread Basic Please correct this (Beginner)
You also need to make the update thread safe.
CODE