Table of Contents

Class TcpBarCodeScanner

Namespace
Acuit.Pinpoint.BarCodeScanning
Assembly
Acuit.Pinpoint.BarCodeScanning.dll

A TCP connection bar code scanner.

public class TcpBarCodeScanner : StreamingBarCodeScanner, IConnectedDevice, IHealthCheck, IDisposable, IAsyncDisposable, IBarCodeScanner, IBarCodeScannerRaw
Inheritance
TcpBarCodeScanner
Implements
Derived
Inherited Members

Constructors

TcpBarCodeScanner(IErrorHandler, ILogger<TcpBarCodeScanner>, ITimeService)

Initializes a new instance of the TcpBarCodeScanner class.

[CLSCompliant(false)]
public TcpBarCodeScanner(IErrorHandler errorHandler, ILogger<TcpBarCodeScanner> logger, ITimeService timeService)

Parameters

errorHandler IErrorHandler

The error handler to use for unexpected background errors.

logger ILogger<TcpBarCodeScanner>

An optional logger. If this is null, no logging will occur.

timeService ITimeService

The time service.

Exceptions

ArgumentNullException

errorHandler is null.

ArgumentNullException

timeService is null.

Properties

Address

Gets or sets the network address for the bar code scanner.

[Required]
public string Address { get; set; }

Property Value

string

Port

Gets or sets the network IP port number for the bar code scanner.

[Range(0, 65535)]
public int Port { get; set; }

Property Value

int

Methods

Dispose(bool)

Closes and releases all resources used by the object.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true when this is in response to a call to Dispose().

Remarks

Derived classes should override this when they have any resources that should be disposed.

When Dispose() is called on the object, Dispose(bool) will be called with true for the parameter value.

When DisposeAsync() is called on the object, DisposeAsyncCore() will be called, and then Dispose(bool) will be called with false for the parameter value.

DisposeAsyncCore()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

protected override ValueTask DisposeAsyncCore()

Returns

ValueTask

A task that represents the asynchronous operation.

Remarks

Derived classes should override this when they have any resources that should be disposed.

When Dispose() is called on the object, Dispose(bool) will be called with true for the parameter value.

When DisposeAsync() is called on the object, DisposeAsyncCore() will be called, and then Dispose(bool) will be called with false for the parameter value.

DoConnectAndGetStreamAsync(CancellationToken)

Connects to the device and gets the Stream to use to communication with the bar code scanner.

protected override Task<Stream> DoConnectAndGetStreamAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token, which indicates that the connection attempt should be aborted.

Returns

Task<Stream>

A task that represents the asynchronous operation. The value of its Result property contains the stream.

Remarks

This might be called from any thread, but it and DoDisconnectAsync(CancellationToken) will never be called concurrently.

Exceptions

Exception

The connection could not be established.

DoDisconnectAsync(CancellationToken)

Disconnects from the device.

protected override Task DoDisconnectAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A CancellationToken that can request that the disconnection process no longer be graceful.

Returns

Task

A task that represents the asynchronous operation.

Remarks

When cancellationToken is signaled, it indicates that the disconnection should still occur, but not gracefully. The implementation should complete its disconnection process as directly as possible, but the returned Task should still reflect a RanToCompletion status (not Canceled).

This might be called from any thread, but it and DoConnectAsync(CancellationToken) will never be called concurrently.