Simon Lacey
asked on
Async File Move in Web App .NET 4.0
I have an ASPX 4.0 page (with Async="true") that contains a user control with a Telerik RadGrid. Each row contains a button that causes an AJAX postback when clicked. When the user clicks the button I am trying to copy a PDF file from one server to this one. This works but the page is waiting until the entire file is completed before the postback completes. I am only wanting to "kickoff" the file copy when the user clicks the button then allow them to continue doing other things without having to wait for the large files to complete copying. I would have figured that doing this asynchronously would have worked but the AJAX panel is still waiting for the operation to complete.
Here is the relevant code that gets called when the user clicks the button:
Public Sub GetPDF(ByVal newFileLocationAndName As String, ByVal origFileLocationAndName As String)
Dim myWebClient As WebClient = New WebClient
AddHandler myWebClient.DownloadFileCo mpleted, AddressOf WebClient_DownloadFileComp leted
myWebClient.DownloadFileAs ync(New Uri(newFileLocationAndName ), origFileLocationAndName)
End Sub
Private Sub WebClient_DownloadFileComp leted(ByVa l sender As Object, ByVal e As System.ComponentModel.Asyn cCompleted EventArgs)
Dim wc As WebClient = DirectCast(sender, WebClient)
RemoveHandler wc.DownloadFileCompleted, AddressOf WebClient_DownloadFileComp leted
wc.Dispose()
End Sub
Here is the relevant code that gets called when the user clicks the button:
Public Sub GetPDF(ByVal newFileLocationAndName As String, ByVal origFileLocationAndName As String)
Dim myWebClient As WebClient = New WebClient
AddHandler myWebClient.DownloadFileCo
myWebClient.DownloadFileAs
End Sub
Private Sub WebClient_DownloadFileComp
Dim wc As WebClient = DirectCast(sender, WebClient)
RemoveHandler wc.DownloadFileCompleted, AddressOf WebClient_DownloadFileComp
wc.Dispose()
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.