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

            lock (this.ThisLock)
            {
                if (_isLoaded)
                {
                    throw new OutoposManagerException("OutoposManager was already loaded.");
                }
                _isLoaded = true;

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                _clientManager.Load(System.IO.Path.Combine(directoryPath, "ClientManager"));
                _serverManager.Load(System.IO.Path.Combine(directoryPath, "ServerManager"));
                _cacheManager.Load(System.IO.Path.Combine(directoryPath, "CacheManager"));
                _connectionsManager.Load(System.IO.Path.Combine(directoryPath, "ConnectionManager"));

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

                tasks.Add(Task.Factory.StartNew(() => _downloadManager.Load(System.IO.Path.Combine(directoryPath, "DownloadManager"))));
                tasks.Add(Task.Factory.StartNew(() => _uploadManager.Load(System.IO.Path.Combine(directoryPath, "UploadManager"))));

                Task.WaitAll(tasks.ToArray());

                stopwatch.Stop();
                Debug.WriteLine("Settings Load {0} {1}", Path.GetFileName(directoryPath), stopwatch.ElapsedMilliseconds);
            }
        }