Table of Contents

Class SynchronousDispatchResponder

Namespace
TechnologySolutions.Rfid.AsciiProtocol
Assembly
TechnologySolutions.Rfid.AsciiProtocol.Core.dll

This is a special TSLAsciiCommandResponder that is inserted into the responder chain to handle synchronous commands. This responder uses its synchronousCommandDelegate to find the currently executing synchronous command. If such a command exists then this responder forwards calls to processReceivedLine:moreLinesAvailable: to the synchronous command's synchronousCommandResponder

public class SynchronousDispatchResponder : IAsciiCommandResponder, IDisposable
Inheritance
SynchronousDispatchResponder
Implements
Inherited Members
Extension Methods

Constructors

SynchronousDispatchResponder()

Initializes a new instance of the SynchronousDispatchResponder class

public SynchronousDispatchResponder()

Properties

LastActivityTime

Gets the last time a line was went sent to or received from the reader (used for timeout)

public DateTime LastActivityTime { get; }

Property Value

DateTime

Methods

Abort()

Aborts the reception of the synchronous command

public void Abort()

Dispose()

Disposes an instance of the SynchronousDispatchResponder class

public void Dispose()

Dispose(bool)

Disposes an instance of the SynchronousDispatchResponder class

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

True to dispose managed as well as native resources

Dispose(IAsciiCommandResponder)

For responders like the SynchronousDispatchResponder this will call dispose if the responder implements IDisposable

public static void Dispose(IAsciiCommandResponder responder)

Parameters

responder IAsciiCommandResponder

The responder to dispose

ProcessReceivedLine(IAsciiResponseLine, bool)

Each correctly terminated line from the device is passed to this method for processing

public bool ProcessReceivedLine(IAsciiResponseLine line, bool moreLinesAvailable)

Parameters

line IAsciiResponseLine

The line to be processed

moreLinesAvailable bool

When YES indicates there are additional lines to be processed (and will also be passed to this method)

Returns

bool

YES if this line should not be passed to any other responder

Release()

Release the lock acquired with WaitToStart(IAsciiCommandSynchronousResponder)

public void Release()

WaitForCommandCompleted(TimeSpan)

Waits for the command to be completed i.e. a response to be received or the command aborted

public bool WaitForCommandCompleted(TimeSpan timeout)

Parameters

timeout TimeSpan

The maximum inactive period to wait for between parts of the response

Returns

bool

True if the response was received OR if the command was aborted. False if the timeout expired

WaitForCommandCompletedAsync(TimeSpan)

Returns a task to wait for the command to be completed i.e. a response to be received or the command aborted

public Task<bool> WaitForCommandCompletedAsync(TimeSpan timeout)

Parameters

timeout TimeSpan

The maximum inactive period to wait for between parts of the response

Returns

Task<bool>

True if the response was received OR if the command was aborted. False if the timeout expired

WaitToStart(IAsciiCommandSynchronousResponder)

Waits for access to the synchronous responder to start executing this command. Must be released with a call to Release()

public void WaitToStart(IAsciiCommandSynchronousResponder commandResponder)

Parameters

commandResponder IAsciiCommandSynchronousResponder

The responder of the command to execute synchronously

Remarks

In addition to acquiring the lock we'll also capture the responder to report to and clear it ready to receive the response once the lock is acquired

WaitToStartAsync(IAsciiCommandSynchronousResponder)

Returns a task to wait for access to the synchronous responder to start executing this command. Must be released with a call to Release()

public Task WaitToStartAsync(IAsciiCommandSynchronousResponder commandResponder)

Parameters

commandResponder IAsciiCommandSynchronousResponder

The responder of the command to execute synchronously

Returns

Task

Remarks

In addition to acquiring the lock we'll also capture the responder to report to and clear it ready to receive the response once the lock is acquired