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

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

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

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

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

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

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

                    tasks.Add(Task.Run(() => _connectionManager.Load()));
                    tasks.Add(Task.Run(() => _messageManager.Load()));

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

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