私は主に昔からのコードスニペットを再利用しています:
public void Start()
{
renewalThread = new Thread(() =>
{
while (!disposed)
{
Thread.Sleep(TimeSpan.FromSeconds(10));
try
{
if (LogUpdated != null)
update();
}
catch (Exception ex)
{
}
}
});
renewalThread.Start();
}
新しい async/await について考えて、これを行うためのよりエレガントな方法はありますか? 次のようなことを行うソリューションとの主な違いは何ですか
Task.run( () =>
{
await Task.delay(10000);
update code
}, __.LongRunning);