当前位置: 首页>>代码示例>>C#>>正文


C# Actions.Execute方法代码示例

本文整理汇总了C#中Actions.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Actions.Execute方法的具体用法?C# Actions.Execute怎么用?C# Actions.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Actions的用法示例。


在下文中一共展示了Actions.Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: test_wait_for_specific_action

    public void test_wait_for_specific_action()
    {
        var timer = new Timer();
        var instance = new Actions(timer);
        var complete = false;
        var count = 0;

        // Run an action which doesn't resolved immediately
        var task = new DeferredAction();
        instance.Execute(task, (ep) =>
        {
            count += 1;
            complete = true;
        });
        Assert(complete == false);

        // Run some other action
        // Notice how all ActionCompleteEvents are skipped until the matching action.
        instance.Execute<SimpleAction>();
        instance.Execute<SimpleAction>();
        instance.Execute<SimpleAction>();
        Assert(count == 0);
        Assert(complete == false);

        // Now we fake the deferred completion, and correctly catch it
        task.Complete();
        Assert(count == 1);
        Assert(complete == true);
    }
开发者ID:shadowmint,项目名称:unity-n-events,代码行数:29,代码来源:ActionsTests.cs

示例2: test_simple_action

    public void test_simple_action()
    {
        var timer = new Timer();
        var instance = new Actions(timer);
        var complete = false;

        // Run an action with no callback
        instance.Execute<SimpleAction>();
        Assert(complete == false);

        // Run an action with a callback
        instance.Execute<SimpleAction>((ep) => { complete = true; });
        Assert(complete == true);
    }
开发者ID:shadowmint,项目名称:unity-n-events,代码行数:14,代码来源:ActionsTests.cs


注:本文中的Actions.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。