Skip to content

Instantly share code, notes, and snippets.

@nuitsjp
Last active February 16, 2016 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuitsjp/21a568baede3b341e386 to your computer and use it in GitHub Desktop.
Save nuitsjp/21a568baede3b341e386 to your computer and use it in GitHub Desktop.
時間の間隔定義にはTimeSpanが便利! ref: http://qiita.com/Nuits/items/00010cf724c6ce6e1974
/// <summary>
/// ポーリング間隔:1分
/// </summary>
private static readonly int PollingInterval = 60 * 1000;
static void Main(string[] args)
{
while (true)
{
// 一定時間スリープする
System.Threading.Thread.Sleep(PollingInterval);
}
}
/// <summary>
/// ポーリング間隔:1分
/// </summary>
private static readonly TimeSpan PollingInterval = TimeSpan.FromMinutes(1);
static void Main(string[] args)
{
while (true)
{
// 一定時間スリープする
System.Threading.Thread.Sleep(PollingInterval);
}
}
/// 日単位
private static readonly TimeSpan PollingInterval = TimeSpan.FromDays(1);
/// 時間単位
private static readonly TimeSpan PollingInterval = TimeSpan.FromHours(1);
/// 分単位
private static readonly TimeSpan PollingInterval = TimeSpan.FromMinutes(1);
/// 秒単位
private static readonly TimeSpan PollingInterval = TimeSpan.FromSeconds(1);
/// ミリ秒単位
private static readonly TimeSpan PollingInterval = TimeSpan.FromMilliseconds(1);
/// 2時間30分
private static readonly TimeSpan PollingInterval =
TimeSpan.FromHours(2) + TimeSpan.FromMinutes(30);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment