Example #1
0
        public static object Load(string file)
        {
            file = file.Trim();
            file = file.Replace("\\", "/");

            if (batching)
            {
                if (!batch.Contains(file))
                {
                    batch.Add(file);
                }
                return(null);
            }

            if (!string.IsNullOrEmpty(file))
            {
                string ext = rext.Match(file).Value.Substring(1).ToLower();
                if (!string.IsNullOrEmpty(ext))
                {
                    if (FileCache.Has(file))
                    {
                        return(FileCache.Get(file, ext));
                    }
                    else
                    {
                        object data = DoLoad(file, ext);
                        if (data != null)
                        {
                            if (FileCache.Add(file, ext, data))
                            {
                                return(FileCache.Get(file, ext));
                            }
                            else
                            {
                                return(data);
                            }
                        }
                    }
                }
            }

            return(null);
        }
Example #2
0
 public void ThreadPoolCallback(object state)
 {
     try {
         object[]      parameters = state as object[];
         System.Action callback   = (System.Action)parameters[1];
         if (!FileCache.Has(file))
         {
             object data = DoLoad(file, ext);
             callback?.Invoke();
             if (data != null)
             {
                 FileCache.Add(file, ext, data);
             }
         }
     } finally {
         if (Interlocked.Decrement(ref pendingThreads) == 0)
         {
             doneEvent.Set();
         }
     }
 }