# Register a class instance (with populated public properties) as a recurring task

**URL:** <https://discuss.hangfire.io/t/register-a-class-instance-with-populated-public-properties-as-a-recurring-task/7311>\
**Category:** question\
**Tags:** recurring\
**Created:** [May 8, 2020, 9:28am UTC](https://discuss.hangfire.io/t/register-a-class-instance-with-populated-public-properties-as-a-recurring-task/7311 "2020-05-08T09:28:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haukur\_Thorsson](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/haukur_thorsson/32/2072_2.png) [@Haukur\_Thorsson](https://discuss.hangfire.io/u/Haukur_Thorsson)\
**Post date:** [May 8, 2020, 9:28am UTC](https://discuss.hangfire.io/t/register-a-class-instance-with-populated-public-properties-as-a-recurring-task/7311/1 "2020-05-08T09:28:47Z")

</div>

Maybe I’m missing something obvious but here goes …

In my system I have all kinds of “tasks”. They are basically classes which implement an interface, called ITask which looks like this:

```
public interface ITask
{
       void Run();
}

```

If the tasks need additional configuration, they can have public properties which the system exposes to the user when the task is being configured, so the user gets a UI where he can populate the properties of the task.

Here’s an example of a task:

```
public class TestTask : ITask
{
   [EditorBrowsable]
   public string TextToDisplay { get; set; }

   public void Run()
   {
       Console.WriteLine(TextToDisplay);
   }
}

```

The task config is then persisted to my database along with a dictionary representing all the public properties and their values. Then I have a factory method that can create instances of these tasks and populate all the stored properties, by reading the config from the database. What I end up with is an instance of the task implementation with all the public properties populated correctly. Essentially just the same as doing this in code:

var recurringTask = new TestTask() { TextToDisplay = “Foobar” };

How can I schedule a RecurringJob in Hangfire to take this recurringTask instance (with all public properties populated) and call the Run() method on it?
