private void WorkerAnalyzeAssets_DoWork(object sender, DoWorkEventArgs e)
        {
            Debug.WriteLine("WorkerAnalyzeAssets_DoWork");
            BackgroundWorker worker = sender as BackgroundWorker;
            IAsset asset = null;

            PublishStatus SASLoc;
            PublishStatus OrigLoc;

            var listae = _MyObservAsset.OrderBy(a => cacheAssetentries.ContainsKey(a.Id)).ToList(); // as priority, assets not yet analyzed

            foreach (AssetEntry AE in listae)
            {
                try
                {
                    asset = _context.Assets.Where(a => a.Id == AE.Id).FirstOrDefault();
                    if (asset != null)
                    {
                        AssetInfo myAssetInfo = new AssetInfo(asset);
                        AE.Name = asset.Name;
                        AE.LastModified = asset.LastModified.ToLocalTime().ToString("G");
                        SASLoc = myAssetInfo.GetPublishedStatus(LocatorType.Sas);
                        OrigLoc = myAssetInfo.GetPublishedStatus(LocatorType.OnDemandOrigin);

                        AssetBitmapAndText assetBitmapAndText = ReturnStaticProtectedBitmap(asset);
                        AE.StaticEncryption = assetBitmapAndText.bitmap;
                        AE.StaticEncryptionMouseOver = assetBitmapAndText.MouseOverDesc;

                        assetBitmapAndText = BuildBitmapPublication(asset);
                        AE.Publication = assetBitmapAndText.bitmap;
                        AE.PublicationMouseOver = assetBitmapAndText.MouseOverDesc;

                        AE.Type = AssetInfo.GetAssetType(asset);
                        AE.SizeLong = myAssetInfo.GetSize();
                        AE.Size = AssetInfo.FormatByteSize(AE.SizeLong);

                        assetBitmapAndText = BuildBitmapDynEncryption(asset);
                        AE.DynamicEncryption = assetBitmapAndText.bitmap;
                        AE.DynamicEncryptionMouseOver = assetBitmapAndText.MouseOverDesc;

                        DateTime? LocDate = asset.Locators.Any() ? (DateTime?)asset.Locators.Min(l => l.ExpirationDateTime).ToLocalTime() : null;
                        AE.LocatorExpirationDate = LocDate.HasValue ? ((DateTime)LocDate).ToLocalTime().ToString() : null;
                        AE.LocatorExpirationDateWarning = LocDate.HasValue ? (LocDate < DateTime.Now.ToLocalTime()) : false;

                        assetBitmapAndText = BuildBitmapAssetFilters(asset);
                        AE.Filters = assetBitmapAndText.bitmap;
                        AE.FiltersMouseOver = assetBitmapAndText.MouseOverDesc;

                        cacheAssetentries[asset.Id] = AE; // let's put it in cache (or update the cache)
                    }
                }
                catch // in some case, we have a timeout on Assets.Where...
                {

                }
                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    return;
                }

            }
            this.BeginInvoke(new Action(() => this.Refresh()), null);
        }
        private void WorkerAnalyzeAssets_DoWork(object sender, DoWorkEventArgs e)
        {

            Debug.WriteLine("WorkerAnalyzeAssets_DoWork");
            BackgroundWorker worker = sender as BackgroundWorker;
            IAsset asset;

            PublishStatus SASLoc;
            PublishStatus OrigLoc;
            int i = 0;

            foreach (AssetEntry AE in _MyObservAsset)
            {
                asset = null;
                try
                {
                    asset = _context.Assets.Where(a => a.Id == AE.Id).FirstOrDefault();
                    if (asset != null)
                    {
                        AssetInfo myAssetInfo = new AssetInfo(asset);

                        SASLoc = myAssetInfo.GetPublishedStatus(LocatorType.Sas);
                        OrigLoc = myAssetInfo.GetPublishedStatus(LocatorType.OnDemandOrigin);
                        AssetBitmapAndText assetBitmapAndText = ReturnStaticProtectedBitmap(asset);
                        AE.StaticEncryption = assetBitmapAndText.bitmap;
                        AE.StaticEncryptionMouseOver = assetBitmapAndText.MouseOverDesc;
                        assetBitmapAndText = BuildBitmapPublication(asset);
                        AE.Publication = assetBitmapAndText.bitmap;
                        AE.PublicationMouseOver = assetBitmapAndText.MouseOverDesc;
                        AE.Type = AssetInfo.GetAssetType(asset);
                        AE.SizeLong = myAssetInfo.GetSize();
                        AE.Size = AssetInfo.FormatByteSize(AE.SizeLong);
                        assetBitmapAndText = BuildBitmapDynEncryption(asset);
                        AE.DynamicEncryption = assetBitmapAndText.bitmap;
                        AE.DynamicEncryptionMouseOver = assetBitmapAndText.MouseOverDesc;
                        DateTime? LocDate = asset.Locators.Any() ? (DateTime?)asset.Locators.Min(l => l.ExpirationDateTime).ToLocalTime() : null;
                        AE.LocatorExpirationDate = LocDate;
                        AE.LocatorExpirationDateWarning = (LocDate < DateTime.Now);
                        assetBitmapAndText = BuildBitmapAssetFilters(asset);
                        AE.Filters = assetBitmapAndText.bitmap;
                        AE.FiltersMouseOver = assetBitmapAndText.MouseOverDesc;
                        i++;
                        if (i % 5 == 0)
                        {
                            this.BeginInvoke(new Action(() => this.Refresh()), null);
                        }
                    }
                }
                catch // in some case, we have a timeout on Assets.Where...
                {

                }
                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    return;
                }

            }
            this.BeginInvoke(new Action(() => this.Refresh()), null);
        }