public
MainPage()
{
this .InitializeComponent();
// 简写
this .Loaded += (sender, e) => { MessageBox.Show( " d " ); MessageBox.Show( " ss " ); };
// 原来写法
this .Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded( object sender, RoutedEventArgs e)
{
// 简写
this .Dispatcher.BeginInvoke(() => MessageBox.Show( " dd " ));
// 原来写法
this .Dispatcher.BeginInvoke(test);
}
void test()
{
MessageBox.Show( " dd " );
}
{
this .InitializeComponent();
// 简写
this .Loaded += (sender, e) => { MessageBox.Show( " d " ); MessageBox.Show( " ss " ); };
// 原来写法
this .Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded( object sender, RoutedEventArgs e)
{
// 简写
this .Dispatcher.BeginInvoke(() => MessageBox.Show( " dd " ));
// 原来写法
this .Dispatcher.BeginInvoke(test);
}
void test()
{
MessageBox.Show( " dd " );
}
结合 Action 的使用