Пример #1
0
        public void Start(string inPath, string outPath)
        {
            if (Directory.Exists(inPath))
            {
                var files = _sourceStorage.Directory.GetFiles(inPath, SearchOption.TopDirectoryOnly).ToArray();
                StartProcessing?.Invoke(this, new ProgressEventArgs(inPath, files.Length));

                foreach (var file in files)
                {
                    var targetDirectory = ProcessFile(file, outPath);
                    //if (!string.IsNullOrEmpty(targetDirectory) && _targetStorage is MtpStorage)
                    //{
                    //    CopyToDevice(file, targetDirectory, outPath);
                    //}
                }
            }
            if (File.Exists(inPath))
            {
                StartProcessing?.Invoke(this, new ProgressEventArgs(inPath, 1));
                var targetDirectory = ProcessFile(inPath, outPath);
                //if (!string.IsNullOrEmpty(targetDirectory) && _targetStorage is MtpStorage)
                //{
                //    CopyToDevice(inPath, targetDirectory, outPath);
                //}
            }
        }
Пример #2
0
        /// <summary>
        /// Starts the DeliveryProcessor
        /// </summary>
        public static void Start(ref List <Delivery> deliveries)
        {
            if (Processing)
            {
                return;
            }

            Processing = true;

            deliveryList = deliveries;

            StartProcessing?.Invoke();
        }
Пример #3
0
        internal static void StartMessageLoop()
        {
            if (MessageLoopRunning)
            {
                ABSLog.ThrowError("An attempt to made to start a message loop while one was already running!");
            }
            MessageLoopRunning = true;

            Task.Run(async() =>
            {
                while (true)
                {
                    // Run immediate processes.
                    while (ImmediateProcesses.TryPeek(out Process immediateProcess))
                    {
                        immediateProcess.ProcessIsRunning = true;
                        await immediateProcess.ExecuteAsync();
                        ImmediateProcesses.TryDequeue(out _);
                    }

                    // Run background processes.
                    if (BackgroundProcesses.TryPeek(out Process backgroundProcess))
                    {
                        backgroundProcess.ProcessIsRunning = true;
                        await backgroundProcess.ExecuteAsync();
                        BackgroundProcesses.TryDequeue(out _);
                    }
                    else
                    {
                        StopProcessing?.Invoke(null, null);

                        waitForNext.Wait();

                        if (!MessageLoopRunning)
                        {
                            return;
                        }

                        waitForNext.Reset();

                        StartProcessing?.Invoke(null, null);
                    }
                }
            });
        }
 protected void OnStartProcessing(EventArgs e)
 {
     StartProcessing?.Invoke(this, e);
 }