您还可以使用扩展方法和lambda来使代码更简洁。
using System.ComponentModel;public static class ISynchronizeInvokeExtensions{ public static void InvokeEx<T>(this T @this, Action<T> action) where T : ISynchronizeInvoke { if (@this.InvokeRequired) { @this.Invoke(action, new object[] { @this }); } else { action(@this); } }}因此,现在您可以
InvokeEx在任何ISynchronizeInvoke上使用,并且能够访问实现类的属性和字段。
this.InvokeEx(f => f.listView1.Items.Clear());



