# How to fire an event when MaxDaysOffline is reached

When the MaxDaysOffline period is exceeded, QLM executes the action specified in the property OfflinePeriodExceededAction.

If your application is developed in .NET, one of the possible actions is to fire an event. To fire an event when MaxDaysOffline is reached, you must create an event handler and register it as follows:

{% code overflow="wrap" %}

```csharp
private void RegisterEvent()
{
    // Assuming lv is an instance of the LicenseValidator class

    // Configure QLM to fire an event
    lv.QlmLicenseObject.OfflinePeriodExceededAction = EOfflinePeriodExceededAction.FireEvent;

    //Specify the event to fire
    lv.QlmLicenseObject.OfflinePeriodExceeded_Event += OnOfflinePeriodExceeded;

    // Enable server side validation
    lv.QlmLicenseObject.ValidateOnServer = true;
}

private void OnOfflinePeriodExceeded(object sender, OfflinePeriodExceeded_EventArgs e)
{
    String msg = String.Format("Offline period exceeded. Error: {0}", e.errorMessage);
    MessageBox.Show(msg);
}
```

{% endcode %}

&#x20;

By default, while the application is running, QLM will try to connect to the server once per day. For testing purposes, you will want to accelerate this process. Add the function below to your application and call it after calling RegisterEvent(). Remember to remove the call to MaxDaysOfflineTest before shipping your product.

&#x20;

{% code overflow="wrap" %}

```csharp
private void MaxDaysOfflineTest()
{
    // Assuming lv is an instance of the LicenseValidator class

    // Start the timer immediately
    lv.QlmLicenseObject.QlmTimerDelayStart = 0;

    // Verify connectivity every minute
    lv.QlmLicenseObject.QlmTimerFrequency = 1;

    // specify the number of days a client can remain offline
    lv.QlmLicenseObject.MaxDaysOffline = 0;

    // Enable NO connectivity simulation mode
    lv.QlmLicenseObject.SimulateNoConnectivity = true;
}
```

{% endcode %}


---

# 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://docs.soraco.co/docs/how-to/how-to-fire-an-event-when-maxdaysoffline-is-reached.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.
