Show / Hide Table of Contents

Class ExecuteSync

Executes synchronously actions.

Inheritance
System.Object
ExecuteSync
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: StoneCo.Framework.Background
Assembly: cs.temp.dll.dll
Syntax
public class ExecuteSync

Methods

Do(Int32, Int32, ActionDelegate)

Execute synchronously an action.

Declaration
public void Do(int repeatQuantity, int interval, ActionDelegate actionDelegate)
Parameters
Type Name Description
System.Int32 repeatQuantity

Quantity of timers that action will be executed. If its defined as a number less than zero, its will execute indefinitely.

System.Int32 interval

Sets interval expressed in miliseconds.

ActionDelegate actionDelegate

Encapsulates a method kind of ActionDelegate that should receive parameters.

Examples
public class FooTest
{
    public FooTest()
    {
        var executeSync = new ExecuteSync();

        executeSync.Do(PrintInteracion, 5, 1000);
        executeSync.Do(PrintInteracionAndMakeStopItAfter3, 10, 1000);
    }

     public void PrintInteracion(int currentInteractionCount, ref bool stop) => Console.WriteLine($"Current interaction: {currentInteractionCount}");

     public void PrintInteracionAndMakeStopItAfter3(int currentInteractionCount, ref bool stop)
     {
         if (currentInteractionCount >= 3) stop = true;
         Console.WriteLine($"Value of stop: {stop}\nCurrent interaction: {currentInteractionCount}");
     }
}

Do(Int32, Int32, Action)

Execute synchronously an action.

Declaration
public void Do(int repeatQuantity, int interval, Action action)
Parameters
Type Name Description
System.Int32 repeatQuantity

Quantity of timers that action will be executed. If its defined as a number less than zero, its will execute indefinitely.

System.Int32 interval

Sets interval expressed in miliseconds.

System.Action action

Encapsulates a method that has no parameters and does not return a value.

Examples
public class FooTest
{
    public FooTest()
    {
        new ExecuteSync().Do(PrintWithoutParameters, 10, 1000);
    }

    public void PrintWithoutParameters() => Console.WriteLine("No parameters passed.");
}
Back to top Generated by DocFX