コード例 #1
0
        private static async Task <int> ReadFileUnmarshalledAsync(
            int fileRef, IInvokeUnmarshalled invokeUnmarshalled, byte[] buffer, long position, int count,
            CancellationToken cancellationToken)
        {
            var taskCompletionSource = new TaskCompletionSource <long>();

            cancellationToken.Register(() => taskCompletionSource.TrySetCanceled());
            var callBackId = Interlocked.Increment(ref nextPendingTaskId).ToString();

            readFileAsyncCalls[callBackId] = taskCompletionSource;

            var startCallBack = invokeUnmarshalled.InvokeUnmarshalled <byte[], string, bool>(
                $"FileReaderComponent.ReadFileUnmarshalledAsync",
                buffer, Json.Serialize(new { position, count, callBackId, fileRef }));

            var longResult = await taskCompletionSource.Task;

            return((int)longResult);
        }
コード例 #2
0
 public FileReaderJsInterop(IJSRuntime jsRuntime, IInvokeUnmarshalled invokeUnmarshalled)
 {
     CurrentJSRuntime   = jsRuntime;
     InvokeUnmarshalled = invokeUnmarshalled;
 }
コード例 #3
0
 public FileReaderService(IJSRuntime jsRuntime, IInvokeUnmarshalled invokeUnmarshalled)
 {
     this._fileReaderJsInterop = new FileReaderJsInterop(jsRuntime, invokeUnmarshalled);
 }