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
파일 보기 프로젝트 열기: GridProtectionAlliance/gsf

공개 메소드들

메소드 설명
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