/// <inheritdoc/> public async Task Store(Proxy proxy) { try { var entity = await proxyRepo.Get(proxy.Id); entity.Country = proxy.Country; entity.LastChecked = proxy.LastChecked; entity.Ping = proxy.Ping; entity.Status = proxy.WorkingStatus; // Only allow updating one proxy at a time (multiple threads should // not use the same DbContext at the same time). await semaphore.WaitAsync(); try { await proxyRepo.Update(entity); } finally { semaphore.Release(); } } catch { /* * If we are here it means a few possible things * - we deleted the job but the parallelizer was still running * - the original proxy was deleted (e.g. from the proxy tab) * * In any case we don't want to save anything to the database. */ } }
public async Task Store(Proxy proxy) { try { var entity = await proxyRepo.Get(proxy.Id); entity.Country = proxy.Country; entity.LastChecked = proxy.LastChecked; entity.Ping = proxy.Ping; entity.Status = proxy.WorkingStatus; // Only allow updating one proxy at a time (multiple threads should // not use the same DbContext at the same time). await semaphore.WaitAsync(); try { await proxyRepo.Update(entity); } finally { semaphore.Release(); } } catch (ObjectDisposedException) { // If we are here, it means we deleted the job but the task manager was still running // so we don't need to put anything in the database and we can safely ignore the exception. } }
public async Task Store(Proxy proxy) { try { var entity = await proxyRepo.Get(proxy.Id); entity.Country = proxy.Country; entity.LastChecked = proxy.LastChecked; entity.Ping = proxy.Ping; entity.Status = proxy.WorkingStatus; await proxyRepo.Update(entity); } catch (ObjectDisposedException) { // If we are here, it means we deleted the job but the task manager was still running // so we don't need to put anything in the database and we can safely ignore the exception. } }
public Proxy GetProxy(int id) { return(_proxyRepository.Get(id)); }