Esempio n. 1
0
        /// <summary>
        /// We will set this when we need more updates, but none are present in the input queue.
        /// </summary>
        //public AutoResetEvent moreUpdatesRequiredEvent;

        public downloadThread(Program.logString logger, AutoResetEvent pollEvent, ConcurrentQueue <downloadedUpdate> outqueue, updateReserverThread updateReserver)
            : base(logger, pollEvent)
        {
            threadname          = "Download thread";
            this.outqueue       = outqueue;
            this.updateReserver = updateReserver;
        }
Esempio n. 2
0
 public processingThread(Program.logString logger, AutoResetEvent poller,
                         ConcurrentQueue <downloadThread.downloadedUpdate> inputQueue, AutoResetEvent downloadRequestEvent,
                         archiveThread archiver,
                         asyncsqlthread sqlThread) : base(logger, poller)
 {
     this.threadname              = "Update processing thread";
     this.queue                   = inputQueue;
     this.asyncSQLParams          = sqlThread;
     this.archiver                = archiver;
     this.UpdateProcessingStarted = downloadRequestEvent;
 }
 protected threadWithLogging(Program.logString logger, AutoResetEvent poller)
 {
     OnLogString    = logger;
     this.pollTimer = poller;
 }
 protected threadWithLogging(Program.logString logger)
 {
     OnLogString = logger;
 }
Esempio n. 5
0
 public asyncsqlthread(Program.logString logger = null) : base(logger)
 {
     this.threadname = "async SQL thread";
 }
Esempio n. 6
0
 public updateReserverThread(Program.logString logger) : base(logger)
 {
     this.threadname = "Update reserver thread";
 }
Esempio n. 7
0
        public static void deleteWithRetry(string toDelete, Program.logString logger)
        {
            if (toDelete == null)
            {
                return;
            }

            if (toDelete.StartsWith("\\\\?\\") == false)
            {
                toDelete = "\\\\?\\" + toDelete;
            }

            int fails = 0;

            while (File.Exists(toDelete) || Directory.Exists(toDelete))
            {
                try
                {
                    if (fails == 0)
                    {
                        if (Directory.Exists(toDelete))
                        {
                            Directory.Delete(toDelete, true);
                        }
                        if (File.Exists(toDelete))
                        {
                            File.Delete(toDelete);
                        }
                    }
                    else
                    {
                        // Eh, maybe it failed because something was read-only? Try shelling out.
                        wsusUpdate.runAndGetStdout("cmd", $"/c rd /s /q {toDelete}");
                    }
                }
                catch (Exception)
                {
                    if (fails > 0)
                    {
                        if (logger != null)
                        {
                            logger($"Failed to delete {toDelete} (attempt {fails}, will retry");
                        }
                    }

                    fails++;
                    Thread.Sleep(100);

                    /*
                     * // f**k it, some other thread can handle it
                     * Thread deletionThread = new Thread((obj) =>
                     * {
                     *  string filename = (string) obj;
                     *  while (Directory.Exists(filename))
                     *  {
                     *      try
                     *      {
                     *          Directory.Delete(filename, true);
                     *      }
                     *      catch (Exception)
                     *      {
                     *          Thread.Sleep(10000);
                     *      }
                     *  }
                     * });
                     * deletionThread.Name = "deletion retry thread";
                     * deletionThread.Start(mountpoint);*/
                }
            }
            if (fails > 0)
            {
                if (logger != null)
                {
                    logger($"Succeeded delete of {toDelete} after {fails} reties");
                }
            }
        }
Esempio n. 8
0
 public archiveThread(Program.logString logger, ConcurrentQueue <string> inputQueue) : base(logger)
 {
     this.threadname = "Archive thread";
     queue           = inputQueue;
 }