aboutsummaryrefslogtreecommitdiff
path: root/VNLib.Plugins.Extensions.Loading/Events/AsyncIntervalAttribute.cs
blob: 13495cfa5021b8e5b901b637e8bc6b19aa7bb3c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;

namespace VNLib.Plugins.Extensions.Loading.Events
{
    /// <summary>
    /// When added to a method schedules it as a callback on a specified interval when 
    /// the plugin is loaded, and stops when unloaded
    /// </summary>
    [AttributeUsage(AttributeTargets.Method)]
    public class AsyncIntervalAttribute : Attribute
    {
        internal readonly TimeSpan Interval;

        /// <summary>
        /// Intializes the <see cref="AsyncIntervalAttribute"/> with the specified timeout in milliseconds
        /// </summary>
        /// <param name="milliseconds">The interval in milliseconds</param>
        public AsyncIntervalAttribute(int milliseconds)
        {
            Interval = TimeSpan.FromMilliseconds(milliseconds);
        }
    }
}