Main Problem to avoid

ActionScheduler is canceling an already scheduled not started action if the same action is scheduled again. Often this is useful, but sometimes you need to schedule the same action more than once with different parameters. In this case you have to build your own actionKey for each scheduled action and provide it in the corresponding actionKey Parameter.

Usage Examples:

Of course you can also combine the different optional Parameters and use the all together...
  • ActionScheduler.ScheduleAction(someAction);
  • ActionScheduler.ScheduleAction(() => someActionWithParams(arg1, arg2));
  • ActionScheduler.ScheduleAction(someAction, runOnGuiThread: true);
  • ActionScheduler.ScheduleAction(someAction, delayInMilliseconds: 500);
  • ActionScheduler.ScheduleAction(someAction, onCompleted: someOtherAction);
  • ActionScheduler.ScheduleAction(someAction, onCompleted: someOtherAction, runOnCompletedOnGuiThread: true);
  • ActionScheduler.ScheduleAction(someAction, scopeKey: "yourScopeKey");
  • ActionScheduler.ScheduleAction(someAction, actionKey: "yourActionKey");

The two main functions are:


This the the Main Function to Schedule an Action.

  • "action" Well, the Action to Schedule - Use new Action() to create a variable or Just Use a function name or a Lamda () => ... here
  • "runOnGuiThread" Wether to run the action in the Background (default) or on the main GUI Thread
  • "scopeKey" A user defined Scope to be able to cancel all scheduled actions with a certain sope
  • "actionKey" if not given in the full Type Name, Method Name and HasCode of the instance is used. Needed if the Same Method needs to be called with different parameters
  • "onCompleted" Action to run after the action given in param action is completed
  • "runOnCompletedOnGuiThread" Wether to run the second action on the main GUI Thread or not - Run Actions that need access to GUI elements like controls on the GUI Thread!
  • "delayInMilliseconds" The delay to wait until the action is started. Default is defined in const DEFAULT_DELAY

public static void ScheduleAction(
Action action,
bool runOnGuiThread = false,
string scopeKey = null,
string actionKey = null,
Action onCompleted = null,
bool runOnCompletedOnGuiThread = true,
int delayInMilliseconds = DEFAULT_DELAY
) {}


Cancel the coresponding actions if they are not started yet!

  • "scopeKey" 2nd priority. Cancel all actions that were scheduled with the same scope key and not started. If action Key is given in this parameter is ignored
  • "actionKey" 1st priority. Cancel the action with this action Key
  • "onlyGuiActions" If true cancels only actions scheduled to run on the main GUI Thread

public static void CancelActions(
string scopeKey = null,
string actionKey = null,
bool onlyGuiActions = false
) {}

In the next release I will integrate a little sample project...

In the meantime: Just try it and have fun!

Last edited Nov 23, 2013 at 9:45 PM by mahop, version 11