开发者

Conditional Delegate Question

Let's say I open a form and want to attach a command to it after it closes.

FormZombie FormZombie = new FormZombie();
FormZombie.Show();
FormZombie.FormClose += delegate{Utili开发者_开发技巧ties.DoSomethingCool()};

How can I make Utilities.DoSomethingCool() trigger only executes depending on what happens in FormZombie?


You can add the conditional check into your delegate:

FormZombie formZombie = new FormZombie(); 
formZombie.Show(); 
formZombie.FormClose += 
    delegate
    {
        if (formZombie.AteEnoughBrains)
            Utilities.DoSomethingCool();
    };
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜