c# 异步方法

1.异步方法的定义

        public string GetValue()
        {
            return "value";
        }
        public async Task<string> GetValueAsync()
        {
            string t = await Task.Run(() => GetValue());
            return t;
        }

2.异步方法的调用

            Task<string> t = GetValueAsync();
            string value = await t;

  

猜你喜欢

转载自www.cnblogs.com/by-lhc/p/9669699.html
今日推荐