Recently I'm learning Task and certailly I touched async await, and i tried to write a simple demo, please kindly help check whether there are any problems in my coding? And why the "x=???" and "GetDataFromDbAsync ends" not be printed on console? I would much appreicate if you could help me out. Thanks a lot.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            Test test = new Test();
            Console.WriteLine("main thread starts...");
            System.Threading.Thread.Sleep(1000);
            test.GetDataFromDb();
            Console.WriteLine("Mainthread end");
            Console.ReadKey();
        }
    }
    class Test
    {
        public void GetDataFromDb()
        {
            Console.WriteLine("GetDataFromDb starts");
            Task.Run(() => GetDataFromDbAsync());
            Console.WriteLine("GetDataFromDb ends");
        }
        public async Task<bool> GetDataFromDbAsync()
        {
            try
            {
                Console.WriteLine("GetDataFromDbAsync starts");
                var x = await ReadingDbAsync();
                Console.WriteLine("x=" + x);
                Console.WriteLine("GetDataFromDbAsync ends");
                return true;
            }
            catch(AggregateException ex)
            {
                Console.WriteLine(ex.Message);
                return false;
            }
        }
        public Task<int> ReadingDbAsync()
        {
            Console.WriteLine("ReadingDbAsync starts");
            System.Threading.Thread.Sleep(3000);
            var task= new Task<int>(() => 100);
            Console.WriteLine("ReadingDbAsync ends");
            return task;
        }
    }
}
The following is the output, demo output here
Output as following:
main thread starts...
GetDataFromDb starts
GetDataFromDb end
Mainthread end
GetDataFromDbAsync starts
ReadingDbAsync starts
ReadingDbAsync ends
**BUT WHY NOT SHOW THE FOLLOWING
x=100
GetDataFromDbAsync ends**
 
     
     
    