mickle026 389 Posted April 5, 2022 Share Posted April 5, 2022 (edited) I have an issue where Im trying to impliment some scheduled tasks. I have the task showing and working , it runs, can be cancelled and completes. However I cannot for the life of figure out why I cannot get the progress bar to update. it just stays at 0.0% Inside the scheduled task class - ScheduledTaskBackupTracks public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress) { CustomProviderBackupTracks d = new CustomProviderBackupTracks(JsonSerializer, libraryManager, _httpClient, configurationManager, _logManager, _current); await d.BackupTracksScheduledTask(new SimpleProgress<double>(), cancellationToken).ConfigureAwait(false); } This has no problem starting the task or stopping it, the contructor and everything is all ok. My code starts in another class - CustomProviderBackupTracks public async Task BackupTracksScheduledTask(IProgress<double> progress, CancellationToken cancellationToken) { // doing stuff { // more code double percent = (double)mAlbumCount / AllAlbum.Length; progress.Report(100 * percent); // more code } } This is where my amateur is showing ! Do I need to do something else to pass the progress?, The cancel token passes into the call just fine. Am I understanding this or not? No errors are thrown. Help with this appreciated.. Edited April 5, 2022 by mickle026 Link to comment Share on other sites More sharing options...
pünktchen 1241 Posted April 5, 2022 Share Posted April 5, 2022 Don't initialize a new progress value in your return function of the task execute method, just use "progress". 1 1 Link to comment Share on other sites More sharing options...
mickle026 389 Posted April 6, 2022 Author Share Posted April 6, 2022 Thank you so much. I can see what I was doing now you pointed it out - duh! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now