本文整理汇总了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);
}
示例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);
}