# Module Async Scheduling

Modules can easily tie in to ColdBox's [async scheduling engine](/v6.x/digging-deeper/promises-async-programming/scheduled-tasks.md) by defining a `config/Scheduler.cfc` file.  This file only needs a `configure` method.  Inside the file, you can define tasks to run asynchronously on a schedule and ColdBox will take care of the rest.

```javascript
component {

    property name="settings" inject="coldbox:moduleSettings:unleashsdk";
    property name="log" inject="logbox:logger:{this}";

    function configure() {
        task( "unleashsdk-refresh-features" )
            .call( getInstance( "UnleashSDK@unleashsdk" ), "refreshFeatures" )
            .every( variables.settings.refreshInterval, "seconds" )
            .before( function() {
                if ( log.canDebug() ) {
                    log.debug( "Starting to fetch new features from Unleash" );
                } 
            } )
            .onSuccess( function( task, results ) {
                if ( log.canInfo() ) {
                    log.info( "Successfully refreshed features", results );
                }
            } )
            .onFailure( function( task, exception ) {
                if ( log.canError() ) {
                    log.error(
                        "Exception when running task [unleashsdk-refresh-features]:",
                        exception
                    );
                }
            } );

        task( "unleashsdk-send-metrics" )
            .call( getInstance( "UnleashSDK@unleashsdk" ), "sendMetrics" )
            .every( variables.settings.metricsInterval, "seconds" )
            .delay( variables.settings.metricsInterval, "seconds" )
            .before( function() {
                if ( log.canDebug() ) {
                    log.debug( "Starting to send metrics to Unleash" );
                } 
            } )
            .onSuccess( function( task, results ) {
                if ( log.canInfo() ) {
                    log.info(
                        "Successfully sent metrics to Unleash features",
                        results
                    );
                }
            } )
            .onFailure( function( task, exception ) {
                if ( log.canError() ) {
                    log.error(
                        "Exception when running task [unleashsdk-send-metrics]:",
                        exception
                    );
                }
            } );
    }

}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://coldbox.ortusbooks.com/v6.x/hmvc/modules/module-async-scheduling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
