示例#1
0
        void ProcessLabeledImage(LabeledImage labeledImage)
        {
            ProcessedImageServer labeledAvImage = new ProcessedImageServer(labeledImage.Name,
                                                                           labeledImage.Label,
                                                                           labeledImage.ByteImage);

            _dispatcher.Post(() =>
            {
                Task t = new Task(() =>
                {
                    ProcessedImageCollection.Add(labeledAvImage);
                    _databaseMailbox.Post(labeledAvImage);
                    _processedImagesAmount++;
                    _addedNewProcessedImage.Set();

                    Console.Write($"[Ready {_processedImagesAmount}/{_newImagesAmount}]");
                    Console.WriteLine($" Image <{labeledAvImage.Name}> added into Database.");

                    if (_processedImagesAmount == _newImagesAmount)
                    {
                        _dispatcherCompletionEvent.Set();
                    }
                });
                t.Start();

                return(t);
            });
        }
示例#2
0
        void AddProcessedImagesFromDataBase(int[] processed_image_id, MyContext db)
        {
            Func <ProcessedImageDB, bool> func = a => IsIdInArray(a.ImageId, processed_image_id);
            var query = db.ProcessedImages.Include(a => a.AdditionalInfo).Where(func);

            foreach (var db_elem in query)
            {
                byte[] byte_image = db_elem.AdditionalInfo.First().ByteImage;
                ProcessedImageServer labeled_image = new ProcessedImageServer(db_elem.ImageName,
                                                                              db_elem.ImageLabel,
                                                                              byte_image);

                _dispatcher.Post(() =>
                {
                    Task t = new Task(() =>
                    {
                        ProcessedImageCollection.Add(labeled_image);
                        _processedImagesAmount++;
                        _addedNewProcessedImage.Set();

                        Console.Write($"[Ready {_processedImagesAmount}/{_newImagesAmount}]");
                        Console.WriteLine($" Image <{labeled_image.Name}> was inside Database.");
                        if (_processedImagesAmount == _newImagesAmount)
                        {
                            _dispatcherCompletionEvent.Set();
                        }
                    });
                    t.Start();

                    return(t);
                });
            }

            IsDatabaseBusy = false;
        }