Table of Contents

Class RoutineBlocker

Namespace
Hi.Common
Assembly
HiGeom.dll

Block the thread to the given delay from the previous block.

public class RoutineBlocker : IMakeXmlSource, IDisposable
Inheritance
RoutineBlocker
Implements
Inherited Members
Extension Methods

Constructors

RoutineBlocker()

Constructor

public RoutineBlocker()

RoutineBlocker(TimeSpan)

Initializes a new instance of the RoutineBlocker class with the specified period.

public RoutineBlocker(TimeSpan period)

Parameters

period TimeSpan

The time period between blocks

RoutineBlocker(XElement)

Initializes a new instance of the RoutineBlocker class from an XML element.

public RoutineBlocker(XElement src)

Parameters

src XElement

The XML element containing the blocker configuration

Fields

XName

Gets the XML element name used for serialization.

public static string XName

Field Value

string

Properties

Period

Delay time between each previous Block().

public TimeSpan Period { get; set; }

Property Value

TimeSpan

Methods

Block()

Delay the thread. The delay time is Period, counted from the previous Block() to the current Block(). The first function call does no delay. If the time between two Block() is over Period, the function call does no delay.

public void Block()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

HasToBlock()

If calling Block() make thread delay, return true; otherwise, false.

public bool HasToBlock()

Returns

bool

Has to block

IsEnabled()

Enable the Block() function.

public bool IsEnabled()

Returns

bool

MakeXmlSource(string, string)

Creates an XML representation of the object. This method may also generate additional resources such as related files.

public XElement MakeXmlSource(string baseDirectory, string relFile)

Parameters

baseDirectory string

The base directory for resolving relative paths

relFile string

The relative file path for the XML source

Returns

XElement

An XML element representing the object's state

Remarks

For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied. The baseDirectory is typically the folder at the nearest configuration file folder. Since the folder can be moving with the configuration file.

SetDisable()

Disables the blocker, canceling any pending operations.

public void SetDisable()

SetEnable(Action)

Enable the Block() function.

public void SetEnable(Action disablingCallback = null)

Parameters

disablingCallback Action