示例#1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
示例#2
0
        public async Task SaveChangesAsync()
        {
            _saving = true;
            List <ChatMessageDto> temp;

            lock (_syncRoot)
            {
                temp             = _pendingMessages;
                _pendingMessages = new List <ChatMessageDto>();
            }
            var context = new MessagesContext();

            context.Configuration.AutoDetectChangesEnabled = false;
            context.Configuration.ValidateOnSaveEnabled    = false;
            // ReSharper disable once AccessToDisposedClosure
            await Task.Run(() => { context.BulkInsert(temp); });

            context.Dispose();
            SaveCompleted.Invoke(this, DateTime.Now);
            _saving = false;
        }