protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
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(); }
public void Dispose() { _context.Dispose(); }