Beispiel #1
0
        void EnqueueServiceResolution <TService>(System.Action <TService> setter, bool blocking)
            where TService : class, IService
        {
            if (blocking)
            {
                _taskQueue.Enqueue(() => {
                    TService service = _serviceResolver.Get <TService>();
                    setter(service);
                });
                return;
            }

            bool     found        = false;
            TService foundService = null;

            _taskQueue.Enqueue(() => {
                _serviceResolver.Get <TService>((result, service) => {
                    foundService = service;
                    setter(service);
                    found = true;
                });
            });

            _taskQueue.Parallelize(() => found, -1, string.Format("find service {0}", typeof(TService).Name)).Done += result => {
                CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("done preparing service {0}: {1}; provider is: {2}", typeof(TService).Name, result,
                                                                                 foundService == null ? "null" : foundService.GetType().Name));
            };
        }