Extending - Threads
Let's take a look at how you might extend Perigee to fit your companies very specific needs. Although we ship with many different connectors, watchers, agents, and synchronization features you may want to add something to the Perigee core system. It is very easy to implement custom threads. This is one the reasons Perigee is so powerful as we don't lock you out of adding and customizing the application.
There are two types of custom threads you can add where both have different execution rules as they allow you create any additional functionality needed for your specific requirements.
Managed Thread
The first type is a managed thread. The ManagedThread calls the callback method when it is started, and doesn't expect that method to return, throw an exception, or exit until the cancellation token is canceled.
When the callback does exit before token cancelation, it will restart the thread a second later expecting the process to start again. If an exception is thrown and is uncaught within the callback, it will be caught in the ManagedThread, and the ExceptionRestartTime property of the manager will be awaited before restarting.
Below is a fully working extension that adds a new method to call from TaskConfig
.
Then to use this custom method on startup.
Expression Thread
This is nearly identical to the managed thread, however it's execution is built on a CRON expression. This changes the way the callback functions slightly.
The Callback Method is ONLY called the expression is at execution time. This means the process is expected to kick off, and end by returning out of the method.
If an exception is thrown, it will be caught in ManagedThread, but no additional delay is added as the next execution period of the CRON expression will simply call the callback again.
The takeaway about the two types:
Expression Threads: Get called, expect to exit.
Managed Threads: Get called, don't expect to exit, and will trigger the restart functionality on uncaught exceptions.
Last updated