Search Results for

    Show / Hide Table of Contents

    Interface IProcessMonitor

    Handles the running of Tasks, with logging and duration. Use as follows:

    public class UsageExample
    {
        private readonly ProcessMonitor _monitor;
    
        public UsageExample(ILogger<UsageExample> logger)
        {
            _monitor = ProcessMonitor.Create(logger, new EventId());
        }
    
        internal async Task<bool> ConsumeProcessMonitor()
        {
            return await _monitor.ProcessAsync<bool>("parent", async () =>
            {
                await _monitor.Child.ProcessAsync("step1", step1);
                bool result = await _monitor.Child.ProcessAsync("step2", step2);
                return result;
            });
        }
    
        async Task<double> step1() => await Task.FromResult(1);
    
        async Task<bool> step2() => true;
    }
    Namespace: LemonEdge.Utils
    Assembly: LemonEdge.Utils.dll
    Syntax
    public interface IProcessMonitor

    Properties

    Child

    Creates a child ProcessMonitor, with the same ILogger and EventId.

    Declaration
    IProcessMonitor Child { get; }
    Property Value
    Type Description
    IProcessMonitor

    Methods

    ProcessAsync<T>(string, Func<Task<T>>)

    Logs that a unit of code is starting. Runs that named unit of code (process). Logs that the unit of code finished, and its duration. See the ProcessMonitor class declaration for usage example.

    Declaration
    Task<T> ProcessAsync<T>(string name, Func<Task<T>> process)
    Parameters
    Type Name Description
    string name

    The name / label to give the process.

    Func<Task<T>> process

    The process itself.

    Returns
    Type Description
    Task<T>

    A task of type T.

    Type Parameters
    Name Description
    T

    The type of the process.

    Extension Methods

    LinqExtensions.AsArray<T>(T)
    LinqExtensions.ToArrayOfOne<T>(T)
    LinqExtensions.ToListOfOne<T>(T)
    MiscExtensions.SetIfNotEqual<T, TP>(T, Expression<Func<T, TP>>, TP)
    WeakReferenceExtensions.WeakReference(object)
    SQLExtensions.ToSQLValue(object, bool)
    ReflectionExtensions.ClearEventInvocations(object, string)
    StringExtensions.ToCSVFormatString(object, Type)
    In this article
    Back to top © LemonEdge Technologies. All rights reserved.