在简单的控制台C#应用程序命令之间暂停 [英] Pauses between commands in simple console C# app
本文介绍了在简单的控制台C#应用程序命令之间暂停的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有简单的如何如有命令之间延迟1秒?我只能想到一些大的周期。我知道了Thread.Sleep但它不是我所期待的 - 我想只用别的东西没有关系的线程。
感谢您的任何想法。
Is there any easy how to e.g. have 1 second delay between commands? I can only think of some large cycles. I know about thread.sleep but it is not what I am looking for - I would like to just use something else without relation to threads. Thanks for any idea
推荐答案
我的认为的你是像<一后HREF =http://msdn.microsoft.com/en-us/library/9k7k7cf0%28VS.80%29.aspx相对=nofollow>收益回报。
这可以让你有传控制权返回给调用代码,然后可以通过您的应用程序进行。该环节都有其使用的一个很好的例子。
This allows you to have the pass control back to the calling code and then can carry on through your app. The link has a good example of its use.
using System;
using System.Collections;
class Test
{
static void Main(string[] args)
{
foreach (string x in Foo())
{
Console.WriteLine (x);
}
}
static IEnumerable Foo()
{
yield return "Hello";
yield return "there";
}
}
这篇关于在简单的控制台C#应用程序命令之间暂停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文