public async Task DownloadAndSave(DownloadParameters parameters, CancellationToken cancellationToken, Action<int, bool> progressCallback, Action downloadFailed)
        {
            try
            {
                int bufferSize = 4096;//Same size as a page size, seems a good size?!?
                using (HttpClient client = new HttpClient())
                {
                    var request = await client.GetAsync(parameters.EndpointUrl, cancellationToken);
                    if (request.IsSuccessStatusCode)
                    {
                        using (FileStream fs = parameters.FileName.OpenWrite())
                        using (var q = await request.Content.ReadAsStreamAsync())
                        {
                            await q.CopyToAsync(fs, bufferSize, cancellationToken);
                        }

                        _dispatcher.Invoke(progressCallback, 100, true);
                    }
                    _dispatcher.Invoke(downloadFailed);
                }
            }
            catch (Exception)
            {
                _dispatcher.Invoke(downloadFailed);
            }
        }
        //public DownloadingUserControl()
        //{
        //    _downloader = new DownloadFromEndpointProvider(Dispatcher);
        //    InitializeComponent();
        //    _downloadParameters = (DownloadParameters)DataContext;
        //    StartDownload();
        //}
        public DownloadingUserControl(DownloadParameters downloadParameters)
        {
            _downloader = new DownloadFromEndpointProvider(this.Dispatcher);
            _downloadParameters = downloadParameters;

            InitializeComponent();
            StartDownload(downloadParameters);
        }
        public MainWindow()
        {
            InitializeComponent();

            var datacontext = new DownloadParameters
            {
                SaveLocation = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                EndPoint = "http://musicbrainz.org/ws/2/artist/5b11f4ce-a62d-471e-81fc-a69a8278c7da?inc=aliases&fmt=json",
                StartDate = DateTime.Today.AddDays(-1),
                EndDate = DateTime.Today
            };

            DataContext = datacontext;

            HomePage initalPage = new HomePage();
            this.Content = initalPage;
        }
 private void StartDownload(DownloadParameters downloadParameters)
 {
     Task.Run(() => _downloader.DownloadAndSave(_downloadParameters, _cancellationTokenSource.Token, Progress, DownloadFailed));
 }