c#异步task示例分享(异步操作)
程序员文章站
2023-12-19 18:25:04
c# task异步操作
复制代码 代码如下:using system;using system.threading;using system.threading.task...
c# task异步操作
复制代码 代码如下:
using system;
using system.threading;
using system.threading.tasks;
namespace consoleapplication18
{
class program
{
static void main(string[] args)
{
func<string, string> _processtimefunc = new func<string, string>((string arg) =>
{
return string.format("{0} {1}", arg, datetime.now);
});
task.factory.fromasync<string, string>(_processtimefunc.begininvoke, _processtimefunc.endinvoke, "zhuzhou", null)
.continuewith((result) =>
{
console.writeline(result.result);
});
console.readline();
}
}
}