Base solution for your next web application
Open Closed

Auto register background jobs #1199


User avatar
0
soulmate created

Hello,

as I learnt I have to register jobs in the post init event:

public override void PostInitialize()
        {
            base.PostInitialize();
            
            var workManager = IocManager.Resolve<IBackgroundWorkerManager>();
            workManager.Add(IocManager.Resolve<MakeInactiveUsersPassiveWorker>());
        }

However, would it be possible to automatic register all jobs that implement an specific interface (like you do for WebApi Service?). I think that would further increase productivity.

Thank you


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    This is an intended implementation. Registering it like that allows us to use same background job with different options. Say that we have a job to check a folder to delete old files. We may want to add the same job twice to watch more than one folder. Also, this registration saves us to investigate background jobs (which would make app startup a bit slower). There was also some more reasons when I design it like that. Anyway, you can write a simple code to accomplish it for your application. We may consider to add such an option.