Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  6. Unity 2017.2 beta is now available for download.
    Dismiss Notice

[3USD] Cron scheduler v.1.0 - Lightweight cron scheduler implementation

Discussion in 'Assets and Asset Store' started by arklay_corp, Jun 15, 2015.

  1. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    189
    Cron scheduler v.1.0
    [​IMG]

    Link to the Asset Store: [HERE]

    This asset provides a lightweight implementation in C# of a cron scheduler adapting the code released in Random Sparks Blog.

    Basically cron will allow you to define a trigger to be executed minutely, hourly, daily, weekly, monthly, yearly, on weekends, on a weekday, or on any interval or range of those. It´s a very syntax for job scheduling used in Unix-like systems for decades.

    For more info about the cron syntax and its power, let me refer you to its Wikipedia page.

    A basic cheat sheet:
    [​IMG]
    In this example the trigger will be fired every Sunday at 2:36 am.

    Every cron schedule contains 5 entries, first for minutes, second for hours, third for days, fourth for months and last one for days of the week.

    Each entry can be:
    • An asterisk: meaning to launch every day, hour, minute…
    • A concrete value:
      • 5: fire at 5am, on May or on Fridays…
    • A range:
      • 1-10: fire each minute from 1 to 10, every day of the day from 1 to 10…
    • A list of values:
      • 1,3,13: fire the trigger at 1am, 3am and 1pm…
    • A divider:
      • */2: on even days, even hours…
      • */5: at 12am, 5am, 10am, 3pm, 8pm…
    • A combination of any of them:
      • 2,3,5-7: on days 2, 3, 5, 6, and 7…
      • 1-10/3: on minutes 1, 4, 7, 10…
      • 2,3,4-10/2: at 2am, 3am, 4am ,6am, 8am and 10am

    It seems complicated but it’s not and almost every configuration can be found on the internet, just googling for example “cron odd hours” (* 1-23/2 * * *).

    The component includes a custom editor with direct access to most used configurations and a quick cheat sheet:

    [​IMG]


    If you have any doubt, problem or feature request please feel free to ask here.
     
    Last edited: Dec 3, 2015
    ilmario likes this.
  2. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    189
    Finally in the asset store :)
     
    ilmario likes this.
  3. ilmario

    ilmario

    Joined:
    Feb 16, 2015
    Posts:
    45
    Hey, I just bought this. Surprised there werent other similar cron solutions, this seems very simple and straight forward - though it hasnt been updated for quite a while.
     
  4. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    189
    Hi @ilmario so far I didn't need to update it, it's being working pretty well so far and, as you say is very simple and straight forward

    Anyway if you found some bug or need some feature to be added, just let me know
     
    ilmario likes this.
  5. ilmario

    ilmario

    Joined:
    Feb 16, 2015
    Posts:
    45
    Glad to hear that @arklay_corp :)

    I found this cron actually after buying your other very impressive asset, Easy Threading.

    Im havent started properly using Easy Threading, but I noticed the "Send Events to Main Thread"-boolean, and I assumed that would work well out of the box since you're the multithreading guru - though multithreading isnt mentioned on the cron asset page.

    Anyway, it seems that checking "Send Events to Main Thread" and defining a onTrigger callback will result in this error:

    Code (CSharp):
    1. get_isPlaying can only be called from the main thread.
    2. Constructors and field initializers will be executed from the loading thread when loading a scene.
    3. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
    4. UnityEngine.Events.UnityEvent:Invoke()
    5. U3D.Cron.CronScheduler:OnCronTrigger() (at Assets/U3D/Cron/CronScheduler.cs:39)
    6. Rlc.Cron.CronObject:ThreadRoutine() (at Assets/U3D/Cron/Rlc.Cron/CronObject.cs:150)
    7.  
    On main thread it works just fine (very nice!).

    In my case I definitely need multithreading for cron .. so, should the multitheading work out of box with the cron asset, or do I need to manually integrate it with Easy Threading?

    (PS: Im using latest Unity 5.5.1)
     
    Last edited: Feb 12, 2017
  6. Gunhi

    Gunhi

    Joined:
    Apr 18, 2012
    Posts:
    286
    could you please create a tutorial video about how to Getting started? even with the Sample scene?
     
  7. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    189
    I think there is no need for a video for this asset. With the asset you have a readme explaining the basic usage and a sample scene.

    Basically:
    1- add the "CronScheduler" component to any gameobject
    2- configure the component (when do you want the event to be raised; every minute, every day...)
    3- add listeners for the event
     
  8. Gunhi

    Gunhi

    Joined:
    Apr 18, 2012
    Posts:
    286
    Does this work on mobile? My purpose is schedule a list of Local notification in some day of month.
     
  9. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    189
    It works on mobile, but i think it will not work for you... out of the box. It needs to be executing for the events to be triggered.

    Unless you modify it slightly and use it to retrieve the information to schedule the local notifications
     
  10. Gunhi

    Gunhi

    Joined:
    Apr 18, 2012
    Posts:
    286
    this does seem to work in Background mode (mobile).
     
  11. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    189
    It should work in background mode until OS decides to kill the app (either after a few minutes or when it needs more memory for other apps) so be very careful with that...