C# 中 SetTimeout 方案
2021-01-22 08:12
标签:timeout end tar response requested ons color lse cell C# 中 延时执行方案,如下,如果同一个DelayedProcess 对象连续调用 SetTimeout ,默认取消前一次调用. 调用示例: C# 中 SetTimeout 方案 标签:timeout end tar response requested ons color lse cell 原文地址:https://www.cnblogs.com/howtrace/p/12083645.html public class DelayedProcess
DelayedProcessstring, string> dp = new DelayedProcessstring, string>();
private void button1_Click(object sender, EventArgs e)
{
Console.WriteLine("{0}:{1}", DateTime.Now, "开始请求");
dp.SetTimeout(2000, (arg) => {
if (arg.IsSuccess)
{
Console.WriteLine("{0}:延时执行{1}", DateTime.Now, arg.request);
}
else {
Console.WriteLine("{0}:延时失败,{1}", DateTime.Now, arg.ex.Message);
}
}, new DelayedProcessstring, string>.Result() { request = "1111" });
}
文章标题:C# 中 SetTimeout 方案
文章链接:http://soscw.com/index.php/essay/45356.html