Giter Site home page Giter Site logo

fluentscheduler's Introduction

logo

logo logo

FluentScheduler

Automated job scheduler with fluent interface for the .NET platform.

JobManager.Initialize();

JobManager.AddJob(
    () => Console.WriteLine("5 minutes just passed."),
    s => s.ToRunEvery(5).Minutes()
);

Learning? Check the documentation!

Comments? Problems? Suggestions? Check the issues!

Want to help? Check the help wanted label!

fluentscheduler's People

Contributors

dnauck avatar eokadas avatar graceatwood avatar hakanl avatar jgeurts avatar mdissel avatar mjamro avatar tallesl avatar thanood avatar urbanbjorkman avatar vkaldi avatar youcandanch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fluentscheduler's Issues

Support UTC time

Currently all scheduling is done through local time. It would be nice to support using UTC time so that schedules for certain times of day can be done without regard to local time.

Getting the current task progress o canceling it

Hello, there is a way in that I can get the progress of the current running task?

It would be nice something like:

foreach (var a in FluentScheduler.TaskManager.AllSchedules)
Console.WriteLine(a.Progress);

It would be nice a way to cancel the task if it is running.

EveryHour

Thank you for the last quick reply, I have another question, what about if I need to run my schedule every full hour. Ex. 14:00, 15:00, 16:00

I know we can "Schedule(Of NewRelic)().ToRunEvery(1).Hours" but will start counting from a present time.

Thank you

Run a task only within working hours

Just taking a look at this library, and it looks interesting. One thing, I don't seem to be able to figure out how to do, though, is to run a task every 10 minutes between normal working hours - e.g. between 8:00 and 16:00 Monday to Friday. Is that possible?

I guess I could always do .ToRunEvery(10).Minutes() and then in the task skip it if it's not within the correct time, but that's not so nice.

What if App stops?

There is no storing possible right now, right?

How can we save our tasks and reload them if the app restarts?

it would already be enough if we had a serializable state object with the task type. of course not possible with actions, but for me it is too unsecure.

Do you have some info about this for me?

Question on Scheduler with specific start date

I have a question regarding a schedule that has a specific start date.
For instance if I schedule an action below:

MyRegistry.Schedule(Task).ToRunOnceAt("27/11/2014 11:30").AndEvery(5).Minutes()

Does the above code mean that the scheduler will execute once on that day at 11:30 and every five minutes from then (11:35, 11:40, 11:45 etc), or does it mean it will run once on that start date and every five minutes from when the schedule was created?

I ask because I seem to notice that the code for .OnEvery(x).Minutes() seems to be based off the time the schedule was created as opposed to the date set in the .ToRunOnceAt(xxx) value.

DelayFor support

Hi!

Given that ToRunOnceIn() runs incorrectly (we have the same problem as with ToRunOnceAt(DateTime.Now.Add...)), I've created a proof of concept for delayed task startup.

https://github.com/vkaldi/FluentScheduler/tree/DelayFor-support

Check out the samples in ConsoleTester.Program.DelayForTest()

  1. There's an extension method DelayFor() that currently attaches only to Seconds()/Minutes() - will add support for the rest
  2. Each schedule now has a DelayRunFor property that defaults to Timespan.Zero
  3. On first execution (in AddSchedules), DelayRunFor is accounted in the calculation

Should I finish finish up the task properly?

Cross-schedule blocking

I'm trying to handle a case where two schedules are doing database work that is causing deadlocks. What I need is for schedule A and schedule B to never be running at the same time.

Is there a way to have one schedule reference another to see it's running. I'd like to have schedule A only execute if schedule B not currently executing. Or even better, if I could have schedule B stop/start schedule A whenever schedule B executes.

//schedule A - every 1 minute
Schedule(() =>
{
//if daily task is NOT running, execute code
}).ToRunEvery(1).Minutes();

//schedule B - every 1 day
Schedule(() =>
{
//execute code
}).ToRunEvery(1).Days();

Seeking New Ownership!

Would anyone like to take over ownership of this project? I have moved on from .net and do not intend to maintain this library. If you're interested, please respond to this issue.

Pause/resume of Schedule

I would like to have the ability to pause a single schedule by name
and then resuming it

Possibly something like

TaskManager.GetSchedule("mytask").Pause();
TaskManager.GetSchedule("mytask").Resume();

Schedule.Id Property

Could you please add an “Id” (int) property to the Schedule type? The “Name” property is useful, but having a numeric Id would be even better. That way schedules could be enumerated. Likewise, a coorespoding WithId() function would be helpful. It’d be better (compiler help) than having to handle string literals (as with Name) and would help enforce uniqueness of schedules within the registry.

private enum ScheduleEnum : byte
{
Hourly = 1,
Daily = 2,
Weekly = 3
}

Schedule(() =>
{
if(TaskManager.RunningSchedules.Any(x => x.Id == (int)ScheduleEnum.Daily)) {
// Return because daily task is running
return;
}
}).WithId(ScheduleEnum.Hourly).ToRunEvery(1).Hour();

Schedule(() =>
{
//code
}).WithId(ScheduleEnum.Daily).ToRunEvery(1).Day();

Schedule task - function with parameters

Hi,

I have MVC app, where i need schedule a lot of task in registry....
I used switch in registry task to data from db for specific type of schedule task

my code example :

case (int)TaskSchedulerType.Monday:
{
Schedule(() =>
{
var task = TaskManager.RunningSchedules.FirstOrDefault(x => x.Name != "OK");
if (task != null)
{
string plannedId = task.Name;
task.Name = "OK";

                                        if ((DateTime.Now - task.NextRunTime).TotalMinutes > 1)
                                            return;

                                        productService.RunPoductTask(Convert.ToInt32(plannedId));
                                        task.Name = plannedId;
                                    }
                                })
                                .WithName(allTasks[i].TaskPlannedId.ToString()).ToRunEvery(0).Weeks()                             .On(DayOfWeek.Monday).At(allTasks[i].FirstRunOn.Hour, allTasks[i].FirstRunOn.Minute);
                                break;
                            }


                        case (int)TaskSchedulerType.Tuesday:
                            {
                                Schedule(() =>
                                {
                                    var task = TaskManager.RunningSchedules.FirstOrDefault(x => x.Name != "OK");
                                    if (task != null)
                                    {
                                        string plannedId = task.Name;
                                        task.Name = "OK";

                                        if ((DateTime.Now - task.NextRunTime).TotalMinutes > 1)
                                            return;

                                        productService.RunPoductTask(Convert.ToInt32(plannedId));
                                        task.Name = plannedId;
                                    }
                                })
                                    .WithName(allTasks[i].TaskPlannedId.ToString()).ToRunEvery(0).Weeks()                                  .On(DayOfWeek.Tuesday).At(allTasks[i].FirstRunOn.Hour, allTasks[i].FirstRunOn.Minute);
                                break;
                            }

This is working very well, in my code i am using name of task than input parameter for function productService.RunPoductTask(Convert.ToInt32(plannedId));
But now a need more parameters for this function...
productService.RunPoductTask(Convert.ToInt32(plannedId), text);
is there some way how to store data for parameters ? For example on db and returning if i need run specific task ?

THANKS for help

How do you use/trigger the exception handling?

I've tried throwing an exception from a ITask derived class but I've been unable to get the RaiseUnobservedTaskException event to fire. The example in the source that throws an exception is commented out.

Thanks!

James

HostingEnvironment.RegisterObject

Hi - thanks for the implementation, very neat. I'm assuming this code is still under active development?

I know this article is a little on the old side, but it raises some points around ASP.NET app domain disposal etc.

http://haacked.com/archive/2011/10/16/the-dangers-of-implementing-recurring-background-tasks-in-asp-net.aspx

Before I start working on a pull request (which may take while, being busy), have you considered the points raised around disposal etc of managed tasks? Should be easy enough to implement, just wanted to double check in case you'd already addressed or explored.

Thanks

Weekly schedule not working as expected

If it is Thursday at 12:40PM and this code is executed,

        Schedule s = this.Schedule(() =>
        {
            // some code to execute
        });
        s.ToRunEvery(1).Weeks().On(DayOfWeek.Thursday).At(12, 45);

shouldn't the task get executed in 5 minutes, at 12:45PM? This doesn't appear to be happening.

Suggestions: Make NonReentrant the default behaviour

Hi, I believe that it would make sense to enable NonReentrant behaviour by default. In most scenarios tasks do not benefit from running on top of one another.

Thanks for a great scheduler though. Im using NonReentrant on all my synchronization tasks.

Ability to pass parameters into a Task?

Hi there!

First I want to say that I love using FluentScheduler thus far!

Second, my team recently created several tasks that need to be parameterized, and as far as I can tell, in FluentScheduler there isn't a way to pass in parameters to a Schedule when creating one in the Registry class. Is this correct, or am I missing something?

If it isn't currently possible, what would you suggest as the best course of action here?

Thanks so much for your time, and I hope to hear from you soon.

All the best!

UnobservedTaskException does not catch exceptions from async/await code

Here's a naive unit test demonstrating that exceptions happening inside of async/await code is not caught:

[TestFixture]
public class Unobserved_task_exceptions
{
    [Test]
    public void Async_exceptions_not_caught()
    {
        var errors = new List<string>();

        TaskManager.UnobservedTaskException += (sender, args) => { errors.Add(args.ExceptionObject.ToString()); };
        TaskManager.Initialize(new FaultySchedule());
        Thread.Sleep(1500);

        Assert.IsNotEmpty(errors);
    }

    public class FaultySchedule : Registry
    {
        public FaultySchedule()
        {
            Schedule(async () => { await new FaultyComponent().Run(); }).ToRunOnceIn(1).Seconds();
        }
    }

    public class FaultyComponent
    {
        public async Task Run()
        {
            await Task.Delay(0);

            throw new Exception("Expected!");
        }
    }
}

Week scheduler problem

Hello,

I'm trying to set a week period task at specific day and time, like this:

schedule.ToRunEvery(0).Weeks().On(DayOfWeek.Wednesday).At(22, 30)
or
schedule.ToRunEvery(1).Weeks().On(DayOfWeek.Wednesday).At(22, 30)

The task is always sheduled to next week, ie. 7-13 days from the scheduling.

Pavel

enum Week: missing Fourth value

Hi,
in Week enum there are vaules for 1st, 2nd, 3rd and last week but i think that should be another value "Fourth".
in fact some months have 5 week and so the last week is not the fourth week.
Thanks

Daily schedule not working

Hello Jim,

I have used fluentSchedular in my MVC application. In that my requirement is email should go before 30 days, 15 days, and 3 days ago. Also email reminder should go before 3 hours and 30 minutes when client date is expires.

I put following code..

in global.asax file..

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);

        ModelBinders.Binders.Add(typeof(DataTableRequestModel), new DataTableRequestModelBinder());
        TaskManager.Initialize(new MyRegistry()); 
    }

then I create a new class file called MyRegistry. In that class file I put following code.
======================================================.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.Mvc;
using FluentScheduler;
using NexusWeb.Data;

namespace NexusWeb
{

myregistryclass

public class MyRegistry : Registry 
{
    public MyRegistry()
    {
        Schedule<ThreeHoursReminder>().ToRunNow().AndEvery(1).Minutes();
        Schedule<ThirtyMinutesReminder>().ToRunNow().AndEvery(1).Minutes().DelayFor(20).Seconds();
        Schedule<ThirtyDaysReminder>().ToRunNow().AndEvery(0).Days().At(10, 05);
        Schedule<FifteenDaysReminder>().ToRunNow().AndEvery(0).Days().At(10, 06);
        Schedule<ThreeDaysReminder>().ToRunNow().AndEvery(0).Days().At(10, 07);
        Schedule<TaskReminder>().ToRunNow().AndEvery(0).Days().At(10, 08);
    }        
}

public class ThreeHoursReminder : ITask
{
    private ICallListRepository _ThreeHoursRepo;
    private ICallListRepository ThreeHoursRepo
    {
        get
        {
            if (_ThreeHoursRepo == null)
            {
                IDependencyResolver resolver = DependencyResolver.Current;
                if (resolver != null) _ThreeHoursRepo = resolver.GetService<ICallListRepository>();
            }
            return _ThreeHoursRepo;
        }
    }

    public void Execute()
    {
        StringBuilder sb = new StringBuilder();

        List<CallList> lst3HoursUsers = ThreeHoursRepo.GetCallListforReminder(180);
        for (int i = 0; i < lst3HoursUsers.Count; i++)
        {
            sb.Clear();
            sb.Append("Hello, <b>" + lst3HoursUsers[i].CallBy + "</b> <br/><br/>");
            sb.Append("Please check the following details for Client :- <br/>");
            sb.Append("Client Name : " + lst3HoursUsers[i].ClientName + "<br/>");
            sb.Append("Client Phone number : " + lst3HoursUsers[i].ClientPhoneNo + "<br/>");
            sb.Append("Contact Person : " + lst3HoursUsers[i].ContactPerson + "<br/><br/>");
            sb.Append("Please check below description when you call to client <br/>");
            sb.Append(lst3HoursUsers[i].Title + "<br/><br/>");
            sb.Append("--<br/>");
            sb.Append("Thanks & Regards<br/>");
            sb.Append("Nexusweb Team<br/>");

            NexusUtility.SendEmail(lst3HoursUsers[i].CallByUserEmail, "Call to client after 3 hours", sb.ToString());
        }            
    }        
}

public class ThirtyMinutesReminder : ITask
{
    private ICallListRepository _ThirtyMinutesRepo;
    private ICallListRepository ThirtyMinutesRepo
    {
        get
        {
            if (_ThirtyMinutesRepo == null)
            {
                IDependencyResolver resolver = DependencyResolver.Current;
                if (resolver != null) _ThirtyMinutesRepo = resolver.GetService<ICallListRepository>();
            }
            return _ThirtyMinutesRepo;
        }
    }

    public void Execute() 
    {
        StringBuilder sb = new StringBuilder();

        List<CallList> lst30MinutesUser = ThirtyMinutesRepo.GetCallListforReminder(30);
        for (int j = 0; j < lst30MinutesUser.Count; j++)
        {
            sb.Clear();
            sb.Append("Hello, <b>" + lst30MinutesUser[j].CallBy + "</b> <br/><br/>");
            sb.Append("Please check the following details for Client :- <br/>");
            sb.Append("Client Name : " + lst30MinutesUser[j].ClientName + "<br/>");
            sb.Append("Client Phone number : " + lst30MinutesUser[j].ClientPhoneNo + "<br/>");
            sb.Append("Contact Person : " + lst30MinutesUser[j].ContactPerson + "<br/><br/>");
            sb.Append("Please check below description when you call to client <br/>");
            sb.Append(lst30MinutesUser[j].Title + "<br/><br/>");
            sb.Append("--<br/>");
            sb.Append("Thanks & Regards<br/>");
            sb.Append("Nexusweb Team<br/>");

            NexusUtility.SendEmail(lst30MinutesUser[j].CallByUserEmail, "Call to client after 30 Minutes", sb.ToString());
        }
    }        
}

public class ThirtyDaysReminder : ITask
{
    private IClientRepository _ThirtyDaysRepo;
    private IClientRepository ThirtyDaysRepo
    {
        get
        {
            if (_ThirtyDaysRepo == null)
            {
                IDependencyResolver resolver = DependencyResolver.Current;
                if (resolver != null) _ThirtyDaysRepo = resolver.GetService<IClientRepository>();
            }
            return _ThirtyDaysRepo;
        }
    }

    public void Execute()
    {
        StringBuilder sb = new StringBuilder();

        List<NexusClient> lst30DaysClient = ThirtyDaysRepo.GetClientListforReminder(30);
        for (int j = 0; j < lst30DaysClient.Count; j++)
        {
            sb.Clear();                                

            sb.Append("Hello, <b>Admin</b> <br/><br/>");
            sb.Append("Please check the following details for Client :- <br/>");
            sb.Append("Client Name : " + lst30DaysClient[j].Name + "<br/>");
            sb.Append("Client Phone number : " + lst30DaysClient[j].PhoneNo + "<br/>");
            sb.Append("Contact Person : " + lst30DaysClient[j].ContactPerson + "<br/><br/>");
            sb.Append("Below is the details of client has purchased service, service due date is : <b>" + lst30DaysClient[j].DueDate.ToString() + "</b><br/>");
            sb.Append(lst30DaysClient[j].ServicePurchaseDetail + "<br/><br/>");
            sb.Append("--<br/>");
            sb.Append("Thanks & Regards<br/>");
            sb.Append("Nexusweb Team<br/>");

            NexusUtility.SendEmail("[email protected]", "Client service expired in next 30 days", sb.ToString());
        }
    }  
}

public class FifteenDaysReminder : ITask
{
    private IClientRepository _FifteenDaysRepo;
    private IClientRepository FifteenDaysRepo
    {
        get
        {
            if (_FifteenDaysRepo == null)
            {
                IDependencyResolver resolver = DependencyResolver.Current;
                if (resolver != null) _FifteenDaysRepo = resolver.GetService<IClientRepository>();
            }
            return _FifteenDaysRepo;
        }
    }

    public void Execute()
    {
        StringBuilder sb = new StringBuilder();

        List<NexusClient> lst15DaysClient = FifteenDaysRepo.GetClientListforReminder(15);
        for (int j = 0; j < lst15DaysClient.Count; j++)
        {
            sb.Clear();

            sb.Append("Hello, <b>Admin</b> <br/><br/>");
            sb.Append("Please check the following details for Client :- <br/>");
            sb.Append("Client Name : " + lst15DaysClient[j].Name + "<br/>");
            sb.Append("Client Phone number : " + lst15DaysClient[j].PhoneNo + "<br/>");
            sb.Append("Contact Person : " + lst15DaysClient[j].ContactPerson + "<br/><br/>");
            sb.Append("Below is the details of client has purchased service, service due date is : <b>" + lst15DaysClient[j].DueDate.ToString() + "</b><br/>");
            sb.Append(lst15DaysClient[j].ServicePurchaseDetail + "<br/><br/>");
            sb.Append("--<br/>");
            sb.Append("Thanks & Regards<br/>");
            sb.Append("Nexusweb Team<br/>");

            NexusUtility.SendEmail("[email protected]", "Client service expired in next 15 days", sb.ToString());
        }
    }
}

public class ThreeDaysReminder : ITask
{
    private IClientRepository _ThreeDaysRepo;
    private IClientRepository ThreeDaysRepo
    {
        get
        {
            if (_ThreeDaysRepo == null)
            {
                IDependencyResolver resolver = DependencyResolver.Current;
                if (resolver != null) _ThreeDaysRepo = resolver.GetService<IClientRepository>();
            }
            return _ThreeDaysRepo;
        }
    }

    public void Execute()
    {
        StringBuilder sb = new StringBuilder();

        List<NexusClient> lst3DaysClient = ThreeDaysRepo.GetClientListforReminder(3);
        for (int j = 0; j < lst3DaysClient.Count; j++)
        {
            sb.Clear();

            sb.Append("Hello, <b>Admin</b> <br/><br/>");
            sb.Append("Please check the following details for Client :- <br/>");
            sb.Append("Client Name : " + lst3DaysClient[j].Name + "<br/>");
            sb.Append("Client Phone number : " + lst3DaysClient[j].PhoneNo + "<br/>");
            sb.Append("Contact Person : " + lst3DaysClient[j].ContactPerson + "<br/><br/>");
            sb.Append("Below is the details of client has purchased service, service due date is : <b>" + lst3DaysClient[j].DueDate.ToString() + "</b><br/>");
            sb.Append(lst3DaysClient[j].ServicePurchaseDetail + "<br/><br/>");
            sb.Append("--<br/>");
            sb.Append("Thanks & Regards<br/>");
            sb.Append("Nexusweb Team<br/>");

            NexusUtility.SendEmail("[email protected]", "Client service expired in next 15 days", sb.ToString());
        }
    }
}

public class TaskReminder : ITask
{
    private ITaskRepository _taskRepo;
    private ITaskRepository TaskRepo
    {
        get
        {
            if (_taskRepo == null)
            {
                IDependencyResolver resolver = DependencyResolver.Current;
                if (resolver != null) _taskRepo = resolver.GetService<ITaskRepository>();
            }
            return _taskRepo;
        }
    }

    public void Execute()
    {
        StringBuilder sb = new StringBuilder();

        List<Task> lstUsersTask = TaskRepo.GetUserTaskListForReminder();
        for (int j = 0; j < lstUsersTask.Count; j++)
        {
            sb.Clear();                

            sb.Append("Hello, <b>" + lstUsersTask[j].TaskAssignTo + "</b> <br/><br/>");
            sb.Append("Please check the following task has been assigned to you :- <br/>");
            sb.Append("Task Name : " + lstUsersTask[j].Title + "<br/>");
            sb.Append("Task duration : " + lstUsersTask[j].TimeDuration + " Hrs.<br/>");
            sb.Append("Task EndDate : " + lstUsersTask[j].EndDate.Value.ToString("dd/MM/yyyy") + " Hrs.<br/>");
            sb.Append("Priority : " + lstUsersTask[j].Priority + "<br/><br/>");                
            sb.Append("Task should be completed within : " + lstUsersTask[j].EstimatedDays + " days. <br/><br/>");
            sb.Append("<u>Below is the task description</u><br/>");
            sb.Append(lstUsersTask[j].Description + "<br/><br/>");
            sb.Append("--<br/>");
            sb.Append("Thanks & Regards<br/>");
            sb.Append("Nexusweb Team<br/>");

            NexusUtility.SendEmail(lstUsersTask[j].TaskAssignToUserEmail, "Task Reminder", sb.ToString());

            var task = TaskRepo.SingleOrDefault(lstUsersTask[j].Id);
            task.LastEmailSentDate = DateTime.Today.Date;
            TaskRepo.Update(task);
        }
    }
}

}

Also Scheduler for each minutes is some time not working. When I am checking this code in local machine it some time works and some time not working.

I have attached a image for code structure I pasted above. please refer that too.

Please let me know where is things going wrong. I am trying to run schedule since last 3 days from above code. But I still wondering whats wrong in above code.

Thanks in advance.

Thanks,
Aslam Ansari

Tasks stop when threadabortexception happens in asp.net 4.0

Hi All,

I have been using fluentscheduler for quite some time but in one application I noticed that tasks stop as soon as there is a threadabortexception or any exception happening in the asp.net 4.0 ( web farms ) application ( by response.redirect ). Has anyone experienced this or have any idea what could be causing this strange behavior ?

Thanks.
Muzzammil

UnobservedTaskException in VB

I´m using VB.NET, when I try to implement in my global.asax the Handler for the UnobservedTaskException I have to pass the "sender" and "eventargs".

AddHandler TaskManager.UnobservedTaskException, TaskManager_UnobservedTaskException(????????)

Private Shared Sub TaskManager_UnobservedTaskException(sender As Task, e As UnhandledExceptionEventArgs)
LogMessage("An error happened with a scheduled task: " & Convert.ToString(e.ExceptionObject))
End Sub

I don´t know how to pass those object, can you give me a tip?

CRON expressions

Hi,
I've chosen your implementation of a task scheduler because I like the codebase and the fact that the code is using the TPL.

I need to extend the library to support the ability to schedule based on cron espressions. I saw that the Schedule CalculateNextRun Func is internal, so It's impossible for me to implement such a thing.

Now I have to import all your codebase in my project, modified for my needs, but this is not what I really want, so it's possible to have a version which enables extensions?

Thanks

Dynamically schedule Task

Hi,

I need to schedule tasks dynamically. For example, Task A, needs to determine when to run Task B and how many such instances of Task B and how long each instance should run.

if I schedule the tasks in the App_start, I think, I am hard coding it to the particular time.

is it possible to schedule outside the Registry class?

Thanks
Bala.

it won't work with nop commerce.

Anyone knows that will this cope with nop commerce?
I have created a nop plugin of task manager.
But the simple task was executed once only.
Please help.
Thanks.

Remove new() constraint from AddTask<T>

Hello,

if you're using a custom ITaskFactory that supports .ctor injection the new() constraint of:

TaskManager.AddTask<T>(...) where T : ITask, new()

is a little bit annoying. Is it possible to remove it in the next version?

Feature to delay first run

Is there a way to delay the first run of a task?

Currently, if I use ToRunNow() it will start the task immediately, but it would be nice if I could delay the first run by some time.

This would be very useful in my scenario, because I use FluentScheduler inside a Windows Service and if I need to start a lot of tasks when the service is starting, it will put a lot of pressure on my system.

If I could use something like ToRunDelayed(40).Seconds() I could distribute the first run of each of the tasks so they would not start all at once.

Scheduled tasks could have a defaulted name rather than null.

By default you have to specify the name of your scheduled task.

If you do:

Schedule<MyTask>().ToRunEvery(10).Minutes();

The name of the task is null. When I get a callback to TaskManager.TaskStart TaskStartScheduleInformation.Name is null.

Could it be changed so that by default the name is equal to the Task class name? (Still null for Actions).

For my project its seems like i'm repeating information in my Repository. My task classes have self explanatory names.

I'll try and get a pull request in later on.

Thanks,

Months Bug

Hi Jim,

The following code will not initialize if the current date is equal to or greater than the scheduled day and time.

private class Tasks : Registry
{
public Tasks()
{
DefaultAllTasksAsNonReentrant();

    Schedule(() =>
    {
        Console.WriteLine(DateTime.Now);
    }).ToRunEvery(1).Months().On(10).At(5, 0);
}

}

The above code throws an ArgumentOutOfRangeException with the message "Number must be either non-negative and less than or equal to Int32.MaxValue or -1. Parameter name: dueTime". It appears that the Timer class is being passed an invalid argument within FleunetScheduler. To reproduce, make sure you call TaskManager.Initialize(new Tasks()) sometime after (but no too far after) the 10th of the month at 5:00 AM. Oddly, initializing more than a few days after the scheduled date is not a problem. It only seems to be a problem within 5 days or so following the scheduled date.

Thanks for taking a look at this issue. Please let me know if you need any additional details.

Kyle

Schedule task to run only during peak hours

Hello
is it possible to schedule a task hourly, but only during peak hours (eg: from 8AM until 5 PM)
It would be nice if we would keep this logic out of the task functionality.

And also: to run a task hourly, but not during the weekend.

Thanks in advance
Klaas

Next run time not calculated

When you set a task:

.ToRunNow()
.AndEvery(30).Seconds();

The first time after it ran, the NextRunTime does not have any value.
From then on, it always gets the correct time for the next run.

HowTo: Some usage questions of recurring events

Hi,
i don't know if this is the right place for my question because i haven't find anything on the web about recurring task:
I need to run my task with this conditions:

  1. run a task every day from 1/6/2013 until 15/7/2013
  2. run a task every Monday, Friday and Sunday of every week,
  3. run a task every 2, 5 and 10 of June every year
  4. run a task every 2nd and 4th friday of every month

Thanks in advance
Stefano

ToRunOnceAt and AndEvery issue

Random r1 = new Random(Guid.NewGuid().GetHashCode());
for (int i = 1; i < 5; i++)
{
int rNext1 = r1.Next(5, 15);
TaskManager.AddTask(() =>
{
}, x => x.WithName(i.ToString()).ToRunOnceAt(DateTime.Now.AddSeconds(rNext1)).AndEvery(10).Seconds());
}

Using the above code I'm trying stagger start and schedules so that they don't all happen at the same time. It works for the initial run time, but after that they all trigger on the same second, instead of being 10 seconds after the run once time.

Any help would be appreciated!

DayOfWeek not working as expected

First off, let me say how fantastic this code is. Thank you Jim!

We're using this library in several services and have run into an issue with the DayOfWeek scheduling. The problem is that the next DayOfWeek is skipped as the next run time.

Let’s say today is Monday and I start the following task schedule:

//run task every Sunday at 6:00 AM
Schedule(() =>
{
Console.WriteLine(DateTime.Now.ToString());
}).ToRunEvery(1).Weeks().On(DayOfWeek.Sunday).At(6, 0);

If today is Monday, I’d expect this task to execute in 6 days (this coming Sunday) and every Sunday after that. Unfortunately, this coming Sunday is skipped and the first time this task will execute is in 13 days (next Sunday).

This issue was also reported by another user on CodePlex:
http://fluentscheduler.codeplex.com/workitem/1

Assembly with strong name

Hi

can you strong name the assembly? all my assemblies are strong named and I can not use a non strong named assembly

FluentScheduler in Nuget store is built referencing the .NET 4.5 pass through dll's

Hi Jim,

As of writing the current version in the NuGet repository, v2.0.39.0 is built using the incorrect referenced dll's. I do not mean the incorrect framework v4.5, but I mean that the compiler is using the incorrect framework dll's.

An exception occurs when using FluentScheduler.dll where .NET version 4.5 is not installed:

How to avoid TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute'

The issue is related to the following blog post:
http://www.mattwrock.com/post/2012/02/29/What-you-should-know-about-running-ILMerge-on-Net-45-Beta-assemblies-targeting-Net-40.aspx

It is not about the ILMerge tool, but about the 'System.Runtime.CompilerServices.ExtensionAttribute' error. In the 4.0 framework this attribute is located in the System.Core dll, but in the 4.5 framework this has moved to the mscorlib dll.

When I pull the current code and built it in my vs 2012 version, a correct dll is outputted. When you check the actual build command for csc.exe, you clearly see the actual 4.0 dll's referenced. These have been moved to C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0, but an older version of the assembly resolver target, resolves the framework dlls to C:\Windows\Microsoft.NET\Framework\v4.0.30319. And that location is the in place update for the 4.5 dlls.

So when you user ildasm to view the IL code, you find that a wrong reference looks like:
[mscorlib]System.Runtime.CompilerServices.ExtensionAttribute
where it should be
[System.Core]System.Runtime.CompilerServices.ExtensionAttribute

If I'm not mistaken, you are using team_city to build Fluent Scheduler, and I do not know how to correct the usage of the referenced framework assemblies in team_city.

I elaborated a lot here, and hope you can fix the incorrect references.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.