protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Пример #2
0
        public static async void ResultToDataBase(object sender, PingerEventArgs args)
        {
            lock (lockObject)
            {
                if (count % 100 == 0)
                {
                    if (MonitorContext != null)
                    {
                        MonitorContext.Dispose();
                    }
                    count++;
                    GC.Collect();
                    MonitorContext = UpkServices.ServiceProvider.GetService <MonitorContext>();
                    MonitorContext.ChangeTracker.AutoDetectChangesEnabled = false;
                    MonitorContext.ChangeTracker.QueryTrackingBehavior    = QueryTrackingBehavior.NoTracking;
                    MonitorContext.ChangeTracker.LazyLoadingEnabled       = false;
                }
            }
            await MonitorContext.Logs.AddRangeAsync(args.PingResults);

            MonitorContext.SaveChanges();
        }
Пример #3
0
 public void Dispose()
 {
     _context.Dispose();
 }