public void LoadCurrenciesFactorsAsync(CurrenciesFactorsLoaderCallback callback)
 {
     ThreadPool.QueueUserWorkItem(
         t =>
         callback(ThrowException
                      ? new CurrenciesFactorsLoaderCalbackState(null, new ApplicationException("Fake"), false)
                      : new CurrenciesFactorsLoaderCalbackState(_factors, null, false)));
 }
        public void LoadCurrenciesFactorsAsync(CurrenciesFactorsLoaderCallback callback)
        {
            if (callback == null)
                throw new ArgumentNullException("callback");
            if (_client != null)
                ThrowMoreThatOneConnectionError();

            _client = new WebClient();
            _client.DownloadStringCompleted += OnClientDownloadStringCompleted;
            _client.DownloadStringAsync(CreateUrlForLoad(), callback);
        }
        public void LoadCurrenciesFactorsAsync(CurrenciesFactorsLoaderCallback callback)
        {
            if (callback == null)
                throw new ArgumentNullException("callback");

            _loader.LoadCurrenciesFactorsAsync(state =>
                                                   {
                                                       if (state.IsCancelled)
                                                       {
                                                           callback(state);
                                                           return;
                                                       }
                                                       if (state.Error == null)
                                                       {
                                                           try { SetCurrencyFactors2Cache(state.Factors); }
                                                           catch (Exception ex) { FireException(new ExceptionEventArgs(ex)); }
                                                           callback(state);
                                                           return;
                                                       }

                                                       FireException(new ExceptionEventArgs(state.Error));

                                                       CurrenciesFactorsPer1UnitInUsd factors = null;
                                                       Exception exception = null;

                                                       try { factors = LoadCurrenciesFactorsFromCache(); }
                                                       catch (Exception ex) { exception = ex; }

                                                       callback(new CurrenciesFactorsLoaderCalbackState(factors, exception, false));
                                                   });
        }
        public void LoadCurrenciesFactorsAsync(CurrenciesFactorsLoaderCallback callback)
        {
            CurrenciesFactorsPer1UnitInUsd factors = null;
            Exception exception = null;

            try
            {
                factors = LoadFactorsFromFile();
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            ThreadPool.QueueUserWorkItem(
                t => callback(new CurrenciesFactorsLoaderCalbackState(factors, exception, false)));
        }