標籤:event ica rgs put ati pes object system component
首先介紹下,winform中可以用this.invoke來實現;wpf中要使用調度器Control.Despite.invoke;
(Action)(()=>
{
})和
new Action (()=>
{
button1.Content = "Action";
})是等價的
using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;namespace WpfApplication1_weituoTest{ /// <summary> /// MainWindow.xaml 的互動邏輯 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void button1_Click(object sender, RoutedEventArgs e) { //button1.Dispatcher.BeginInvoke((Action)(() => //{ // button1.Content = "Action"; //})); button1.Dispatcher.BeginInvoke(new Action (()=> { button1.Content = "Action"; })); } }}
C#の----Func,Action,predicate在WPF中的應用