A thread is considered a new process. You can't directly pass data between the two.
Let's say you are using a progress bar to update a status and you don't want it to cause the main thread to hang. You put it in a new thread but you wouldn't be able to access it. At least not in the way you proposed it.But as I said before both the timer and a thread are completely different in their uses.
Also timers don't really cause lag, It depends on what you set the tick count to be and what you are actually doing in the timer. Threading can cause just as many issues especially if you don't clean up after yourself. However the same can be said for anything.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace CSharp_multithreading { public partial class Form1 : Form { public Form1() { InitializeComponent(); } int Max = 60000; int i = 0; private void Form1_Load(object sender, EventArgs e) { progressBar1.Maximum = Max; Thread threadFill = new Thread(Thread_FillProgressBar); threadFill.Start(); } private void Thread_FillProgressBar() { for (i = 0; i <= Max; i++) { accessControl(); } } private void accessControl() { if (InvokeRequired) { Invoke(new MethodInvoker(accessControl)); } else { progressBar1.Value = i; ShowInTaskbar = true; } } } }
BackgroundWorker and ProgressBar demo - CodeProject
But that's not entirely true.