Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support task custom arguments #65

Closed
aijorgenson opened this issue Jan 7, 2016 · 11 comments
Closed

Support task custom arguments #65

aijorgenson opened this issue Jan 7, 2016 · 11 comments

Comments

@aijorgenson
Copy link

I want to dynamically schedule a task with custom arguments.

I was hoping I could do something like below:

    CustomTask myTask= new CustomTask ();
    myTask.customvariable= customvariable;
    myTask.customvariabletwo= customvariabletwo;
    TaskManager.AddTask<myTask>(s => s.ToRunOnceAt(task.Time));

However, I found out that this is not valid.

@aijorgenson
Copy link
Author

Found another way around it for my application, however this would be a very good feature.

@aijorgenson aijorgenson reopened this Jan 7, 2016
@tallesl tallesl added the on hold label Mar 2, 2016
@tallesl tallesl changed the title No way to dynamically schedule task with custom arguments Support task custom arguments Mar 2, 2016
@tallesl
Copy link
Contributor

tallesl commented Mar 2, 2016

I'm putting this on "on hold" (for comments and opinions from others).

Increasing flexibility may also increase complexity (the more options you give less abstraction you do).

@frapid
Copy link

frapid commented May 8, 2016

Please consider supporting 'JobId' which is super useful to identify jobs during schedules. We currently use another scheduler which supports this feature.

@tallesl
Copy link
Contributor

tallesl commented May 9, 2016

@frapid

You can assign a name to your schedule, does that work out for you?

// Assigning a name in your registry:
Schedule(() => { }).WithName("MySchedule");

// Getting the schedule somewhere else:
var mySchedule = JobManager.GetSchedule("MySchedule");

@frapid
Copy link

frapid commented May 10, 2016

@tallesl, I am afraid, it won't work for us.

What we have is a multi-tenant web application which allows you to create a new tenant (website) when you visit the installation page-->"anydomain.com/install". The page would schedule the installation job with a key (or JobId) anydomain.com. When the installation job (IJob) is fired by the scheduler, we would want to know that the tenant to be created is anydomain.com.

@tallesl
Copy link
Contributor

tallesl commented May 12, 2016

@frapid

I see. If I change the library to support the following would it work for you?

public class WebsiteJob : IJob
{
    public string Domain { get; set; }

    public void Execute()
    {
        // do something with the domain
    }
}

// somewhere in your running code
var job = new WebsiteJob { Domain = "anydomain.com" };
JobManager.AddJob(job, s => s.ToRunOnceAt(date));

@frapid
Copy link

frapid commented May 13, 2016

@tallesl, this is perfect!

@tallesl
Copy link
Contributor

tallesl commented May 13, 2016

Implemented on version 4.1.0.

Thank you for suggesting the feature guys 👍

@tallesl tallesl removed the on hold label May 13, 2016
@frapid
Copy link

frapid commented May 14, 2016

Amazing job, kudos to you @tallesl! This solution feels better than what I have been using on another library.

I am migrating Frapid to CoreCLR. I want to replace the existing task scheduler with FluentScheduler. What is the ETA of this feature to arrive in nuget package?

Thanks a million again!

@tallesl
Copy link
Contributor

tallesl commented May 14, 2016

@frapid It's already on NuGet

@AlonAm
Copy link

AlonAm commented Sep 2, 2016

Would be useful to be able to add parameters to a job AND use IoC
For example:

JobManager.AddJob(s => s.WithParameter("Param1", myParam).ToRunOnceAt(date));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants