Unosquare
    Show / Hide Table of Contents

    Class DelayProvider

    Represents logic providing several delay mechanisms.

    Inheritance
    Object
    DelayProvider
    Implements
    IDisposable
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Swan.Threading
    Syntax
    public sealed class DelayProvider : IDisposable
    Examples

    The following example shows how to implement delay mechanisms.

    using Swan.Threading;
    
    public class Example
    {
        public static void Main()
        {
            // using the ThreadSleep strategy
            using (var delay = new DelayProvider(DelayProvider.DelayStrategy.ThreadSleep))
            {
                // retrieve how much time was delayed
                var time = delay.WaitOne();
            }
        }
    }

    Constructors

    DelayProvider(DelayProvider.DelayStrategy)

    Initializes a new instance of the DelayProvider class.

    Declaration
    public DelayProvider(DelayProvider.DelayStrategy strategy = DelayProvider.DelayStrategy.TaskDelay)
    Parameters
    Type Name Description
    DelayProvider.DelayStrategy strategy

    The strategy.

    Properties

    Strategy

    Gets the selected delay strategy.

    Declaration
    public DelayProvider.DelayStrategy Strategy { get; }
    Property Value
    Type Description
    DelayProvider.DelayStrategy

    Methods

    Dispose()

    Declaration
    public void Dispose()

    WaitOne()

    Creates the smallest possible, synchronous delay based on the selected strategy.

    Declaration
    public TimeSpan WaitOne()
    Returns
    Type Description
    TimeSpan

    The elapsed time of the delay.

    Implements

    System.IDisposable

    Comments

    Back to top Copyright © 2017-2019 Unosquare