1.直接启动线程执行
//4.0写法
new Thread(() =>
{
TimeClearHander(m);
}) { IsBackground = true }.Start();
//net 4.5 的语句 //System.Threading.Tasks.Task.Run(() =>
//Task.Run(() =>
//{
// TimeClearHander(m);
//});
2.
List<Task> taskList = new List<Task>();
TaskFactory taskFactory = new TaskFactory();
taskList.Add(taskFactory.StartNew(() =>
{
//
}));
//等待所有线程结束
Task.WaitAll(taskList.ToArray());
3. Thread无参
Thread thread = new Thread(new ThreadStart(PlayMusic));
thread.IsBackground = true;
thread.Start();
4.Thread有参
Thread thread = new Thread(new ParameterizedThreadStart(setSecond));
thread.IsBackground = true;
thread.Start(new Object() { });
跨线程修改
txty.Invoke((MethodInvoker)delegate
{
txty.Text = "";
});