public async Task <IActionResult> Create([Bind("Id,File,Modified,SizeKb,ProductName")] Download download) { if (ModelState.IsValid) { _context.Add(download); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(download)); }
public async void CheckQuery(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { await Task.Delay(5000); if (queryUpdate.Count == 0 && queryAdd.Count == 0) { continue; } object[] temp; if (queryUpdate.Count > 0) { temp = new object[queryUpdate.Count + 10]; queryUpdate.CopyTo(temp); queryUpdate.Clear(); foreach (object obj in temp) { if (obj != null) { _context.Update(obj); } } } if (queryAdd.Count > 0) { temp = new object[queryAdd.Count + 10]; queryAdd.CopyTo(temp); queryAdd.Clear(); foreach (object obj in temp) { if (obj != null) { _context.Add(obj); } } } int x = 0; while (true) { try { _context.SaveChanges(); break; } catch { } x++; if (x >= 10) { Log("Query Too many tries"); break; } await Task.Delay(500); } } }