I have some problems downloading or uploading a file (WebClient.DownloadFileAsync | UploadFileAsync or HttpWebRequest) and calling SignalR-hub methods at the same time:
SignalR signals were stopped until the file was downloaded. It is like all signalr calls enqueuing. All incoming calls are made further (after downloading the file).
My code snippet:
hubProxy.Invoke("TraceDocumentUploadingRequest", callerId, fileName, "File loading started ", 0); DownloadFileByKey(fileKey, (progressPercentage, bytesSent) => { hubProxy.Invoke("TraceDocumentUploadingRequest", callerId, fileName, "File loading in progress", progressPercentage); }); hubProxy.Invoke("TraceDocumentUploadingRequest", callerId, fileName, "File loading finished", 100);
The second call to the "TraceDocumentUploadingRequest" hub method (in the file upload handler) will be made in the hub after the file has finished loading.
The file upload handler is executed both in the current thread and in another (associated with the implementation of the DownloadFileByKey method) - the result is the same.
How can I avoid this behavior and force calls to the hub method at the right time?
signalr signalr-hub signalr.client
Dmitry
source share