Jump to content

Scheduled Task Simple Progress in async task


mickle026

Recommended Posts

mickle026

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 by mickle026
Link to comment
Share on other sites

pünktchen

Don't initialize a new progress value in your return function of the task execute method, just use "progress".

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...