Class SyncedLogListener
A log listener that synchronizes the ProcessLog(LogEntry) call to any context.
That is, it is safe to attach to the EntryEvent a GUI element such as a Form or a TextBox.
SEE: Post(SendOrPostCallback, object) which reverses the responsibility of thread synchronization.
Client code has just to link to EntryEvent and then process the passed LogEntry safely.
The LogEntry provides methods such as AsJson(), AsList(), etc. for getting a string representation of the entry.
SEE: https://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/
public class SyncedLogListener : LogListener
- Inheritance
-
SyncedLogListener
- Inherited Members
- Extension Methods
Constructors
SyncedLogListener()
Constructor.
public SyncedLogListener()
Methods
ProcessLog(LogEntry)
Called by the Logger to pass LogInfo to a log listener.
CAUTION: The Logger calls its Listeners asynchronously, that is from inside a thread. Thus Listeners should synchronize the ProcessLogInfo() call. Controls need to check if InvokeRequired.
NOTE: This listener synchronizes this call to any context.
public override void ProcessLog(LogEntry Entry)
Parameters
EntryLogEntry
ProcessLogSynced(LogEntry)
Called by the Logger to pass LogInfo to a log listener.
This is synchronized and safe as it is executed outside the Logger thread.
public virtual void ProcessLogSynced(LogEntry Entry)
Parameters
EntryLogEntry
Events
EntryEvent
Occurs when a new LogEntry is available.>
public event EventHandler<LogEntryArgs> EntryEvent