You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace AnonymousMethod
|
|
|
|
|
{
|
|
|
|
|
class DelegateInvoke : Form
|
|
|
|
|
{
|
|
|
|
|
MethodInvoker mi;
|
|
|
|
|
|
|
|
|
|
public DelegateInvoke()
|
|
|
|
|
{
|
|
|
|
|
// 델리게이트 타입이 아닌 무명메서드는 invoke 할 수 없음
|
|
|
|
|
//this.Invoke(delegate { this.Text = "Wrong Way"; });
|
|
|
|
|
|
|
|
|
|
mi = new MethodInvoker(delegate()
|
|
|
|
|
{
|
|
|
|
|
this.Text = "Left Click!";
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.MouseUp += DelegateInvoke_MouseUp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DelegateInvoke_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
this.Invoke(mi);
|
|
|
|
|
else if (e.Button == MouseButtons.Right)
|
|
|
|
|
this.Invoke((MethodInvoker)delegate
|
|
|
|
|
{
|
|
|
|
|
this.Text = "Right Click!";
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|