Created an application that checks for updates on the server every 5 minutes. The application can only run one on the local machine, I control it via mutex:
instanceMutex = new Mutex(true, @"Global\" + Assembly.GetExecutingAssembly().GetType().GUID.ToString(), out createdNew); //Local if (!createdNew) { MessageBox.Show("1mf-alno Updater запущена у другого пользователя. Нельзя запускать две копии 1mf-alno Updater на одном компьютере. Обновления для вас не доступны."); instanceMutex = null; Current.Shutdown(); return; } The class that checks for updates made through the singleton pattern, I will not post all its code, only the constructor with the implementation of the singleton:
private static FPTClass instance; public static FPTClass Instance { get { if (instance == null) { instance = new FPTClass(host, user, pass); } return instance; } } private FPTClass(string hostIP, string userName, string password) { try { //отдельный поток для progressBar worker = new BackgroundWorker(); worker.WorkerReportsProgress = true; worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.ProgressChanged += worker_ProgressChanged; string catalogUpd = ""; using (wiupDataContext dcUser = new wiupDataContext()) { catalogUpd = dcUser.RegKeys.FirstOrDefault(x => x.key == SingleApp.superpro.serialNum).catalog.Trim(); } host = hostIP + catalogUpd + "/"; user = userName; pass = password; //запускаем таймер проверки обновления на сервере ftp timer.Elapsed += (sender, args) => { if (processing || !isOk) return; processing = true; try { if (ftpResponse != null) { //на всякий случай ftpResponse.Close(); ftpRequest = null; } checkNewCatalog(); processing = false; } catch (Exception ex) { SingleApp.notifyIcon.ShowBalloonTip("Ошибка обновления каталога.", ex.Message, BalloonIcon.Error); processing = false; } }; timer.Start(); } catch (Exception e) { SingleApp.utilityClass.ДобавитьЗаписьВЛог(e, "tNgStN"); } } During the update process, an error occurs that is fixed on SQL Server, the cause of the error is clear, but from the screenshot you can see that the record is duplicated, i.e. at the time of the error, there were 2 threads that caused this code almost simultaneously, why is this happening? Where is the second stream formed? How can I track this? 
pendUpd.Single()is related to the code in question. How I understood - almost no. The question should contain a minimal, self-sufficient and reproducible example . - PashaPash ♦