public static Func <MemoryMappedViewStream, object, Internal.OperationStatus> Wrap(SynchronousReadingDelegateWithParameterAndResult externalDelegate) { return((MemoryMappedViewStream stream, object parameter) => { if (externalDelegate == null) { return Internal.OperationStatus.Completed; } return (Internal.OperationStatus)externalDelegate.Invoke(stream.AsRandomAccessStream(), parameter); }); }
/// <summary> /// Reads and removes a message from the queue. This method is thread-safe. /// </summary> /// <param name="readingDelegate">Custom delegate to read using message's stream.</param> /// <param name="parameter">Delegate parameter object.</param> /// <param name="timeout">Operation timeout.</param> /// <returns> /// ChannelStateOperationResult with ChannelState and OperationStatus.Completed, OperationStatus.QueueIsEmpty, OperationStatus.Timeout, /// OperationStatus.DelegateFailed, OperationStatus.RequestedLengthIsGreaterThanLogicalAddressSpace, OperationStatus.RequestedLengthIsGreaterThanVirtualAddressSpace, /// or any OperationStatus returned by readingDelegate. /// </returns> public ChannelStateOperationResult Read(SynchronousReadingDelegateWithParameterAndResult readingDelegate, object parameter, TimeSpan timeout) { return(new ChannelStateOperationResult(_internal.Read(DelegateHelper.Wrap(readingDelegate), parameter, timeout))); }