Beispiel #1
0
 public void DoAddStudent()
 {
     Task.Run(async() =>
     {
         while (true)
         {
             try
             {
                 _logger.LogInformation("这是日志");
                 var guid = Guid.NewGuid();
                 _db.T_Student.Add(new EF.DataBase.Entities.T_Student()
                 {
                     Address = $"这是地址_{guid}",
                     ClassId = 1,
                     Name    = $"这是学生i{guid}",
                     Sex     = 1
                 });
                 await _db.SaveChangesAsync();
                 _serviceB.DoSomething();
                 await Task.Delay(5000);
             }
             catch (Exception ex)
             {
                 _logger.LogError(ex, "发生错误了");
             }
         }
     });
 }
 public async Task DoSomething() => await _serviceB.DoSomething();