Exemple #1
0
        /// <summary>
        /// Add Work to Worker
        /// </summary>
        /// <param name="sourcePath">The Source of the File to be copied</param>
        /// <param name="destinationPath">The Destination where the File should be copied over to</param>
        public static void AddWork(string sourcePath, string destinationPath)
        {
            WorkingClassElement wo = new WorkingClassElement();

            wo.sourcePath      = sourcePath;
            wo.destinationPath = destinationPath;
            workingClassElements.Add(wo);

            if (_counterDic.ContainsKey(Path.GetExtension(sourcePath)))
            {
                _counterDic[Path.GetExtension(sourcePath)] = (Int32.Parse(_counterDic[Path.GetExtension(sourcePath)]) + 1).ToString();
            }
            else
            {
                _counterDic.Add(Path.GetExtension(sourcePath), "1");
            }
        }
Exemple #2
0
        private static async Task internalDoWork(bool copy = true)
        {
            while (hasWork())
            {
                WorkingClassElement wo = workingClassElements.First();
                if (copy)
                {
                    await wo.CopyFile();
                }
                else
                {
                    await wo.MoveFile();
                }

                workingClassElements.Remove(wo);
            }
            finishWork();
        }