Nov 05, 2012, 3:57 PM
[CLOSED] TaskManager not returning a 200 response until long running task has ended
I have a need to download large files. While the file is downloading I would like to use the taskmanager to check if the download is complete. If the download is complete then I need to refresh a grid. The download is started by clicking on a hyperlink and then the task starts. The task polls for a change in a session value. Once it finds that the session value has changed the task should stop.
Looking at Fiddler, I see that a page is opened that starts the download as expected (result of the window.location) and I see that the polling starts as expected BUT the taskmanager does not return a response until the document has completed downloading. I have attatched images to see. For the file specified there were 9 trips to the server for the task and all of them remained with no response until the download response was completed. 10 connections were open. This is causing a huge contention on our servers and many users are complaining. I can remove the task but I need to know what is the best resolution. The end goal is that once the download process completes, I have to refresh a grid on the MyDocuments page with the download date information.
I have removed the window.location = '' and then the task runs fine (I added a button to test stopping it). I believe it is how I am starting the download. I have to redirect to another page. The page never opens because we clear the response and then write the stream back. Is what I am trying to do possible?
Markup
Looking at Fiddler, I see that a page is opened that starts the download as expected (result of the window.location) and I see that the polling starts as expected BUT the taskmanager does not return a response until the document has completed downloading. I have attatched images to see. For the file specified there were 9 trips to the server for the task and all of them remained with no response until the download response was completed. 10 connections were open. This is causing a huge contention on our servers and many users are complaining. I can remove the task but I need to know what is the best resolution. The end goal is that once the download process completes, I have to refresh a grid on the MyDocuments page with the download date information.
I have removed the window.location = '' and then the task runs fine (I added a button to test stopping it). I believe it is how I am starting the download. I have to redirect to another page. The page never opens because we clear the response and then write the stream back. Is what I am trying to do possible?
Markup
<ext:XScript ID="XScript1" runat="server"> <script type="text/javascript"> var imageID;
function linkTermRefClickHandler(urlForDownload, imageIDSelected) { // imageID so we know which folder to select imageID = imageIDSelected; // start the file download window.location = urlForDownload; // show a mask Ext.net.Mask.show({ msg: 'Downloading Document...' }); // start the task #{TaskManager1}.startTask(0); }
</script> </ext:XScript>
<ext:TaskManager ID="TaskManager1" runat="server"> <Tasks> <ext:Task TaskID="Task1" AutoRun="false" Interval="10000" > <DirectEvents> <Update OnEvent="RefreshProgress" Before="extraParams.SelectedImageID = imageID;" /> </DirectEvents> </ext:Task> </Tasks> </ext:TaskManager>
CodeBehind:
Protected Sub RefreshProgress(ByVal sender As Object, ByVal e As Ext.Net.DirectEventArgs) Dim sDownloadStatus = CStr(HttpContext.Current.Session("DownloadStatus")) If sDownloadStatus = "Complete" Then HttpContext.Current.Session("DownloadStatus") = "Idle" Dim iImageID = e.ExtraParams.Item("SelectedImageID") ResourceProxyMgr.AddScript("{0}.stopTask(0); {1}.refreshTree({1}, {2}); Ext.net.Mask.hide();", TaskManager1.ClientID, Grid1.TreeClientID, iImageID) End If End Sub
Last edited by Daniil; Nov 09, 2012 at 2:55 PM.
Reason: [CLOSED]