I am developing a web part which has to parse a list of files on the server side and to output a report. The problem is that this opperation can last for a big amount of time.
I have decided to make the processing of the files in a separate thread and to load the web part content instant with a message like "Loading...." when the results are parse an event will be fired up and the content of the web part will pe updated.
I have found a lot of posts with the following solution
- http://msdn.microsoft.com/en-us/magazine/cc163587.aspx
- http://markitup.com/Posts/Post.aspx?postId=1fded0e9-e871-4e4a-a419-c1a770174cf1 (the idea is the same)
PROBLEM IS that I don't have in my solution the .aspx file in which I can adjust the Async="true"
parameter in the @Page
directive.
Does anyone knows where is this file or how it can be added to be handled corectly by the web part.
P.S. I have tried to execute the task with a BackgroundWorker
but it rises the same error as with Page.RegisterAsyncTask
. The error is: "Asynchronous operations are not allowed in this context. Page starting an asynchronous operation has to have the Async attribute set to t开发者_开发问答rue and an asynchronous operation can only be started on a page prior to PreRenderComplete event."
WebParts can run asynchronously/multi-threaded. Register the appropriate event handlers via Page.RegisterAsyncTask. You'll specify the method that should be invoked asynchronously, as well as the callback method to which control will return once processing is complete.
http://daniellarson.wordpress.com/2006/06/26/asynchronous-webparts-in-asp-net-2-0/
http://daniellarson.wordpress.com/2006/07/16/asynchrounous-asp-net-webparts-for-sharepointmoss/
精彩评论