.NET3.5下用Lambda简化跨线程访问窗体控件,避免繁复的delegate,Invoke
1,错误的代码是:
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;namespace WindowsFormsApplication5{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private string s = "http://www.chenjiliang.com/"; private void Form1_Load(object sender, EventArgs e) { new System.Threading.Thread(ShowTime).Start(); } private void ShowTime() { this.SafeInvoke(() => { textBox1.Text = DateTime.Now.ToString(); }); } }}
?