资源简介
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace asyncAndawait
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(“我是主线程,线程ID:{0}“ Thread.CurrentThread.ManagedThreadId);
TestAsync();
Console.ReadLine();
}
static async Task TestAsync()
{
Console.WriteLine(“调用GetReturnResult()之前,线程ID:{0}。当前时间:{1}“ Thread.CurrentThread.ManagedThreadId DateTime.Now.ToString(“yyyy-MM-dd hh:MM:ss“));
var name = GetReturnResult();
//var ss=name.GetAwaiter();
Console.WriteLine(“调用GetReturnResult()之后,线程ID:{0}。当前时间:{1}“ Thread.CurrentThread.ManagedThreadId DateTime.Now.ToString(“yyyy-MM-dd hh:MM:ss“));
Console.WriteLine(“此时的 name 的类型是 {0}{1}“ name DateTime.Now.ToString());
Console.WriteLine(“下面准备调用 await name“);
Console.WriteLine(“得到GetReturnResult()方法的结果:{0}。当前时间:{1}“await name DateTime.Now.ToString(“yyyy-MM-dd hh:MM:ss“));
}
static async Task GetReturnResult()
{
Console.WriteLine(“执行Task.Run之前 线程ID:{0}“ Thread.CurrentThread.ManagedThreadId);
return await Task.Run(() =>
{
Thread.Sleep(3000);
Console.WriteLine(“GetReturnResult()方法里面线程ID: {0}“ Thread.CurrentThread.ManagedThreadId);
return “我是返回值“;
});
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-10-16 11:22 asyncAndawait2\
目录 0 2020-10-16 11:22 asyncAndawait2\asyncAndawait\
目录 0 2018-08-06 14:12 asyncAndawait2\asyncAndawait\.vs\
目录 0 2018-08-06 14:12 asyncAndawait2\asyncAndawait\.vs\asyncAndawait\
目录 0 2018-08-06 14:12 asyncAndawait2\asyncAndawait\.vs\asyncAndawait\v15\
文件 46592 2018-08-30 19:24 asyncAndawait2\asyncAndawait\.vs\asyncAndawait\v15\.suo
目录 0 2018-08-06 14:12 asyncAndawait2\asyncAndawait\.vs\asyncAndawait\v15\Server\
目录 0 2018-08-22 14:26 asyncAndawait2\asyncAndawait\.vs\asyncAndawait\v15\Server\sqlite3\
文件 0 2018-08-06 14:12 asyncAndawait2\asyncAndawait\.vs\asyncAndawait\v15\Server\sqlite3\db.lock
文件 450560 2018-08-22 14:26 asyncAndawait2\asyncAndawait\.vs\asyncAndawait\v15\Server\sqlite3\storage.ide
目录 0 2018-08-21 20:01 asyncAndawait2\asyncAndawait\asyncAndawait\
文件 167 2020-10-16 11:22 asyncAndawait2\asyncAndawait\asyncAndawait\App.config
文件 1751 2018-08-21 20:01 asyncAndawait2\asyncAndawait\asyncAndawait\Program.cs
目录 0 2018-08-06 14:12 asyncAndawait2\asyncAndawait\asyncAndawait\Properties\
文件 1324 2018-08-06 14:12 asyncAndawait2\asyncAndawait\asyncAndawait\Properties\AssemblyInfo.cs
文件 2365 2020-10-16 11:22 asyncAndawait2\asyncAndawait\asyncAndawait\asyncAndawait.csproj
目录 0 2018-08-06 14:12 asyncAndawait2\asyncAndawait\asyncAndawait\bin\
目录 0 2020-10-16 11:22 asyncAndawait2\asyncAndawait\asyncAndawait\bin\Debug\
文件 8192 2020-10-16 11:23 asyncAndawait2\asyncAndawait\asyncAndawait\bin\Debug\asyncAndawait.exe
文件 167 2020-10-16 11:22 asyncAndawait2\asyncAndawait\asyncAndawait\bin\Debug\asyncAndawait.exe.config
文件 17920 2020-10-16 11:23 asyncAndawait2\asyncAndawait\asyncAndawait\bin\Debug\asyncAndawait.pdb
文件 22984 2020-10-16 11:22 asyncAndawait2\asyncAndawait\asyncAndawait\bin\Debug\asyncAndawait.vshost.exe
文件 167 2020-10-16 11:22 asyncAndawait2\asyncAndawait\asyncAndawait\bin\Debug\asyncAndawait.vshost.exe.config
文件 490 2010-03-17 22:39 asyncAndawait2\asyncAndawait\asyncAndawait\bin\Debug\asyncAndawait.vshost.exe.manifest
目录 0 2018-08-06 14:12 asyncAndawait2\asyncAndawait\asyncAndawait\obj\
目录 0 2020-10-16 11:23 asyncAndawait2\asyncAndawait\asyncAndawait\obj\Debug\
文件 6706 2020-10-16 11:22 asyncAndawait2\asyncAndawait\asyncAndawait\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2020-10-16 13:07 asyncAndawait2\asyncAndawait\asyncAndawait\obj\Debug\TempPE\
文件 0 2018-08-06 14:12 asyncAndawait2\asyncAndawait\asyncAndawait\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2018-08-06 14:12 asyncAndawait2\asyncAndawait\asyncAndawait\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2018-08-06 14:12 asyncAndawait2\asyncAndawait\asyncAndawait\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
............此处省略7个文件信息
- 上一篇:C#唤起微信刷脸支付摄像头
- 下一篇:Quartz.NET定时任务框架
相关资源
- Unity摄像机分辨率自适应设计尺寸脚本
- unity 2d-extras-master插件
- polyvav2D-1.5.2_BehaviorDesigner.unitypackage
- unity读取Excel
- 软键盘(Package_KeyBoard.unitypackage)
- videoMonitor实时监控
- unity5圣典中文API手册v0.02.chm
- Unity 房间游览
- C#简单连接查询sqlite数据库
- 百塞尔曲线粒子插件(.unitypackage)
- 通过程序自动填充并提交ASP.NET表单(
- 皮带传送、齿轮unity
- unity3d脚本学习教程
- c# + sqlite demo(增删改查)
- Unity日历插件
- 轮询RabbitMQ消息队列
- HMI-with-WPF-part-3-Communication-with-multipl
- Unity5实战:使用C#和Unity开发多平台游
- C# 操作 RabbitMQ
- RabbitMQ消息的发送和接收C#
- Unity5.0切水果游戏C#
- 24652561RevitWPFAddin.zip
- WPF圆润的TabItem和TabControl
- Unity2D小游戏——炸弹人类似qq堂的小
- 俄罗斯方框UNITY项目案例包含代码
- HelixToolkitWPF中文手册.rar
- Home Credit Default Riskdata
- C#实现封装SPC过程能力工具类ProcessC
- unity 键鼠控制摄像机移动 脚本
- Unity通过TCP接收服务端数据
评论
共有 条评论