C# Класс GSF.Threading.SynchronizedOperationBase

Base class for operations that cannot run while they is already in progress.
This class handles the synchronization between the methods defined in the ISynchronizedOperation interface. Implementers should only need to implement the ExecuteActionAsync method to provide a mechanism for executing the action on a separate thread.
Наследование: ISynchronizedOperation
Показать файл Открыть проект

Открытые методы

Метод Описание
Run ( ) : void

Executes the action on this thread or marks the operation as pending if the operation is already running.

When the operation is marked as pending, it will run again after the operation that is currently running has completed. This is useful if an update has invalidated the operation that is currently running and will therefore need to be run again.

This method does not guarantee that control will be returned to the thread that called it. If other threads continuously mark the operation as pending, this thread will continue to run the operation indefinitely.

RunOnce ( ) : void

Executes the action on this thread or marks the operation as pending if the operation is already running.

When the operation is marked as pending, it will run again after the operation that is currently running has completed. This is useful if an update has invalidated the operation that is currently running and will therefore need to be run again.

RunOnceAsync ( ) : void

Executes the action on another thread or marks the operation as pending if the operation is already running.

When the operation is marked as pending, it will run again after the operation that is currently running has completed. This is useful if an update has invalidated the operation that is currently running and will therefore need to be run again.

TryRun ( ) : void

Attempts to execute the action on this thread. Does nothing if the operation is already running.

This method does not guarantee that control will be returned to the thread that called it. If other threads continuously mark the operation as pending, this thread will continue to run the operation indefinitely.

TryRunOnce ( ) : void

Attempts to execute the action on this thread. Does nothing if the operation is already running.

TryRunOnceAsync ( ) : void

Attempts to execute the action on another thread. Does nothing if the operation is already running.

Защищенные методы

Метод Описание
ExecuteAction ( ) : bool

Executes the action once on the current thread.

ExecuteActionAsync ( ) : void

Executes the action on a separate thread.

Implementers should call ExecuteAction on a separate thread and check the return value. If it returns true, that means it needs to run again. The following is a sample implementation using a regular dedicated thread. protected override void ExecuteActionAsync() { Thread actionThread = new Thread(() => { while (ExecuteAction()) { } }); actionThread.Start(); }

SynchronizedOperationBase ( System.Action action ) : System

Creates a new instance of the SynchronizedOperationBase class.

SynchronizedOperationBase ( System.Action action, Action exceptionAction ) : System

Creates a new instance of the SynchronizedOperationBase class.

Описание методов

ExecuteAction() защищенный Метод

Executes the action once on the current thread.
protected ExecuteAction ( ) : bool
Результат bool

ExecuteActionAsync() защищенный абстрактный Метод

Executes the action on a separate thread.
Implementers should call ExecuteAction on a separate thread and check the return value. If it returns true, that means it needs to run again. The following is a sample implementation using a regular dedicated thread. protected override void ExecuteActionAsync() { Thread actionThread = new Thread(() => { while (ExecuteAction()) { } }); actionThread.Start(); }
protected abstract ExecuteActionAsync ( ) : void
Результат void

Run() публичный Метод

Executes the action on this thread or marks the operation as pending if the operation is already running.

When the operation is marked as pending, it will run again after the operation that is currently running has completed. This is useful if an update has invalidated the operation that is currently running and will therefore need to be run again.

This method does not guarantee that control will be returned to the thread that called it. If other threads continuously mark the operation as pending, this thread will continue to run the operation indefinitely.

public Run ( ) : void
Результат void

RunOnce() публичный Метод

Executes the action on this thread or marks the operation as pending if the operation is already running.
When the operation is marked as pending, it will run again after the operation that is currently running has completed. This is useful if an update has invalidated the operation that is currently running and will therefore need to be run again.
public RunOnce ( ) : void
Результат void

RunOnceAsync() публичный Метод

Executes the action on another thread or marks the operation as pending if the operation is already running.
When the operation is marked as pending, it will run again after the operation that is currently running has completed. This is useful if an update has invalidated the operation that is currently running and will therefore need to be run again.
public RunOnceAsync ( ) : void
Результат void

SynchronizedOperationBase() защищенный Метод

Creates a new instance of the SynchronizedOperationBase class.
protected SynchronizedOperationBase ( System.Action action ) : System
action System.Action The action to be performed during this operation.
Результат System

SynchronizedOperationBase() защищенный Метод

Creates a new instance of the SynchronizedOperationBase class.
protected SynchronizedOperationBase ( System.Action action, Action exceptionAction ) : System
action System.Action The action to be performed during this operation.
exceptionAction Action The action to be performed if an exception is thrown from the action.
Результат System

TryRun() публичный Метод

Attempts to execute the action on this thread. Does nothing if the operation is already running.
This method does not guarantee that control will be returned to the thread that called it. If other threads continuously mark the operation as pending, this thread will continue to run the operation indefinitely.
public TryRun ( ) : void
Результат void

TryRunOnce() публичный Метод

Attempts to execute the action on this thread. Does nothing if the operation is already running.
public TryRunOnce ( ) : void
Результат void

TryRunOnceAsync() публичный Метод

Attempts to execute the action on another thread. Does nothing if the operation is already running.
public TryRunOnceAsync ( ) : void
Результат void