Exemple #1
0
        public void Load()
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            lock (_lockObject)
            {
                if (_isLoaded)
                {
                    throw new CoreManagerException("CoreManager was already loaded.");
                }
                _isLoaded = true;

#if DEBUG
                var stopwatch = new Stopwatch();
                stopwatch.Start();
#endif

                {
                    var tasks = new List <Task>();

                    tasks.Add(Task.Run(() => _cacheManager.Load()));
                    tasks.Add(Task.Run(() => _networkManager.Load()));

                    Task.WaitAll(tasks.ToArray());
                }

                {
                    var tasks = new List <Task>();

                    tasks.Add(Task.Run(() => _downloadManager.Load()));

                    Task.WaitAll(tasks.ToArray());
                }

#if DEBUG
                stopwatch.Stop();
                Debug.WriteLine("CoreManager Load: {0}", stopwatch.ElapsedMilliseconds);
#endif
            }
        }