Exemple #1
0
        private async Task <long> BlobWriteAsyncWorker(ulong blobId, byte[] data, long position, CancellationToken ct = default(CancellationToken))
        {
            await TaskUtilities.SwitchToBackgroundThread();

            var request = await BlobWriteRequest.WriteAsync(this, blobId, data, position, ct);

            return(await request.Task);
        }
Exemple #2
0
        public async Task <long> BlobWriteAsync(ulong blobId, byte[] data, long position, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (_runTask == null)
            {
                throw new InvalidOperationException("Host was not started");
            }

            using (CancellationTokenUtilities.Link(ref cancellationToken, _cts.Token)) {
                try {
                    await TaskUtilities.SwitchToBackgroundThread();

                    var request = await BlobWriteRequest.WriteAsync(this, blobId, data, position, cancellationToken);

                    return(await request.Task);
                } catch (OperationCanceledException ex) when(_cts.IsCancellationRequested)
                {
                    throw new RHostDisconnectedException(Resources.Error_RHostIsStopped, ex);
                }
            }
        }