Пример #1
0
        /// <summary>
        /// Get Cached Asset
        /// </summary>
        /// <param name="assetPath">Path to asset. Should be handle-able by the asset locator</param>
        /// <returns>Task that returns the cached asset</returns>
        public async Task <ICachedAsset> GetAsync(string assetPath)
        {
            //Get or create cache entry
            if (!CacheDictionary.TryGetValue(assetPath, out var entry))
            {
                entry = new AssetCacheEntry(assetPath, LocateAssetAsync(assetPath), _assetLoader.Unload);
                CacheDictionary.Add(assetPath, entry);
            }

            //Wait for the task to finish
            if (!entry.Task.IsCompleted)
            {
                await entry.Task;
            }

            return(entry.GetCachedAsset());
        }
Пример #2
0
 public CachedAsset(AssetCacheEntry entry)
 {
     _disposed   = false;
     _cacheEntry = entry;
     _cacheEntry.Increment();
 }