using System;
using System.Text;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
public static void Main()
{
Console.WriteLine($"主线程:\t\t\t线程Id:【{Environment.CurrentManagedThreadId}】\t后台线程:【{Thread.CurrentThread.IsBackground}】\t使用线程池:【{Thread.CurrentThread.IsThreadPoolThread}】\t当前时间:【{DateTime_Now_ToString()}】");
string result = GetAwaitString("abc123").Result;
Console.WriteLine("结果:" + result);
Console.WriteLine("执行完毕:" + DateTime_Now_ToString());
Console.ReadLine();
}
public static string DateTime_Now_ToString()
{
return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff");
}
private static async Task<string> GetAwaitString(string str)
{
/*
C#中await Task.Run 返回值
最新推荐文章于 2024-05-29 16:11:20 发布