Volume Control
Application-specific hotkeys for Windows
VolumeControl.Log.Helpers.ThreadedActionQueue Class Reference

Manages a background thread to execute queued actions. More...

Inheritance diagram for VolumeControl.Log.Helpers.ThreadedActionQueue:
Collaboration diagram for VolumeControl.Log.Helpers.ThreadedActionQueue:

Public Member Functions

void Flush ()
 Blocks the caller until the background thread has finished processing the queue. More...
 
bool Flush (int timeoutMs)
 Blocks the caller until the background thread has finished processing the queue, or until the specified timeout has elapsed. More...
 
bool Flush (int timeoutMs, bool exitContext)
 Blocks the caller until the background thread has finished processing the queue, or until the specified timeout has elapsed. More...
 
void Dispose ()
 Terminates the background thread. Does not flush the queue. More...
 

Protected Member Functions

 ThreadedActionQueue ()
 Instantiates a new ThreadedActionQueue instance. More...
 
void Enqueue (Action action)
 Adds the specified action to the queue. More...
 

Detailed Description

Manages a background thread to execute queued actions.

Constructor & Destructor Documentation

◆ ThreadedActionQueue()

VolumeControl.Log.Helpers.ThreadedActionQueue.ThreadedActionQueue ( )
protected

Instantiates a new ThreadedActionQueue instance.

Member Function Documentation

◆ Dispose()

void VolumeControl.Log.Helpers.ThreadedActionQueue.Dispose ( )

Terminates the background thread. Does not flush the queue.

◆ Enqueue()

void VolumeControl.Log.Helpers.ThreadedActionQueue.Enqueue ( Action  action)
protected

Adds the specified action to the queue.

Parameters
actionA delegate to add to the action queue.

Referenced by VolumeControl.Log.AsyncLogWriter.LogMessage().

Here is the caller graph for this function:

◆ Flush() [1/3]

void VolumeControl.Log.Helpers.ThreadedActionQueue.Flush ( )

Blocks the caller until the background thread has finished processing the queue.

◆ Flush() [2/3]

bool VolumeControl.Log.Helpers.ThreadedActionQueue.Flush ( int  timeoutMs)

Blocks the caller until the background thread has finished processing the queue, or until the specified timeout has elapsed.

Parameters
timeoutMsHow many milliseconds to wait before returning early, or (-1) to wait indefinitely.
Returns
true when the queue was successfully flushed before timing out; otherwise false.

◆ Flush() [3/3]

bool VolumeControl.Log.Helpers.ThreadedActionQueue.Flush ( int  timeoutMs,
bool  exitContext 
)

Blocks the caller until the background thread has finished processing the queue, or until the specified timeout has elapsed.

Parameters
timeoutMsHow many milliseconds to wait before returning early, or (-1) to wait indefinitely.
exitContexttrue to exit the synchronization domain for the context before waiting & reacquire it afterwards; otherwise, false.
For more information, see this StackOverflow answer.
Returns
true when the queue was successfully flushed before timing out; otherwise false.

The documentation for this class was generated from the following file: