Gemstone Common Library
Show/Hide TOC

# ISupportBinaryImageExtensionsParseBinaryImageFromStreamAsync Method

Asynchronously parses a binary image from the specified Stream into an object that implements ISupportBinaryImage.

## Definition

Namespace: Gemstone.IO.Parsing
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.159 -- Release Build+a612c25bc0e1c87e5766544ec4650d2ebcfddcf4
C#
View Source Request Example

    public static Task<int> ParseBinaryImageFromStreamAsync(
    	this ISupportBinaryImage imageSource,
    	Stream stream,
    	bool readExactly = false,
    	bool clearArray = false,
    	CancellationToken cancellationToken = default
    )

VB
View Source Request Example

    <ExtensionAttribute>
    Public Shared Function ParseBinaryImageFromStreamAsync (
    	imageSource As ISupportBinaryImage,
    	stream As Stream,
    	Optional readExactly As Boolean = false,
    	Optional clearArray As Boolean = false,
    	Optional cancellationToken As CancellationToken = Nothing
    ) As Task(Of Integer)

C++
View Source Request Example

    public:
    [ExtensionAttribute]
    static Task<int>^ ParseBinaryImageFromStreamAsync(
    	ISupportBinaryImage^ imageSource,
    	Stream^ stream,
    	bool readExactly = false,
    	bool clearArray = false,
    	CancellationToken cancellationToken = CancellationToken()
    )

JavaScript
View Source Request Example

    Gemstone.IO.Parsing.ISupportBinaryImageExtensions.ParseBinaryImageFromStreamAsync = function(imageSource, stream, readExactly, clearArray, cancellationToken);

#### Parameters

imageSource ISupportBinaryImage
  The ISupportBinaryImage instance into which the binary image will be parsed.
stream Stream
  The Stream from which the binary image will be read.
readExactly Boolean (Optional)
  Specifies whether the method should read exactly the number of bytes required to fill the binary image. If true, the method will ensure the exact number of bytes is read; otherwise, it reads as many bytes as are available.
clearArray Boolean (Optional)
  Clears any rented buffers of their contents so that a subsequent consumer will not see the previous consumer's content. If false, default, the array's contents are left unchanged.
cancellationToken CancellationToken (Optional)
  A token to monitor for cancellation requests.

#### Return Value

Task Int32
A task that represents the asynchronous operation. The task result contains the number of bytes successfully parsed.

#### Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ISupportBinaryImage. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

## Remarks

This method uses a buffer rented from a shared ArrayPoolT to read the binary image. The buffer is returned to the pool after the operation completes.

## Exceptions

ArgumentNullException | Thrown if imageSource or stream is null.
OperationCanceledException | Thrown if the operation is canceled via the cancellationToken.

## See Also

#### Reference

ISupportBinaryImageExtensions Class
Gemstone.IO.Parsing Namespace