在继续下载或上传文件(WebClient.DownloadFileAsync|UploadFileAsync或通过HttpWebRequest)并同时调用SignalR-hub方法时,我遇到了一些问题:
SignalR调用已停止,直到文件加载完成。看起来是这样的:所有的signalr调用都在排队。所有入队的调用都会进一步执行(文件加载后)。
我的代码片段:
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);第二个"TraceDocumentUploadingRequest“集线器方法调用(在文件加载处理程序中)将在文件下载完成后在集线器上执行。
文件加载处理程序在当前线程或另一个线程(与DownloadFileByKey方法实现相关)中执行-结果相同。
我如何避免这种行为,并在正确的时间强制中心方法调用?
发布于 2015-07-24 21:36:18
总结David Fowl的评论,这个问题是SignalR版本1.1.3中的一个错误,但在更高版本中得到了修复。具体地说,2.0.0版本
https://stackoverflow.com/questions/19136630
复制相似问题