views:

295

answers:

1

Here's the scenario. I have a number of Sharepoint Web Parts which display data to the user in a grid format. They all connect to a navigation web part which the user can use to select parameters for each of the data grids. On the back end, the grid web part calls a DI container to get an "IDataProvider," which queries some SoR and returns a data table.

Here's what I want to do: I want the grid web parts to be executed in parallel rather than in series, since many of our "IDataProvider" implentations make calls to web services. I tried to spool up a BackgroundWorker in the WebPartManager.ConnectionsActivated event, with a "wait" flag in the "OnPreRender" method, but the server threw an error saying that asynchronous operations were not allowed. When I tried to set the "Async" flag to true on the page layout, I get an error telling me that sharepoint explicity forbids setting the "Async" flag to true.

Is there a workaround for this?

+1  A: 

DivisionByZorro,

First off, I love the name :-)

Fear not: WebParts can run asynchronously/multi-threaded without too much extra work. You'll simply need to 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.

Daniel Larson provides some nice coverage in his articles here (http://daniellarson.spaces.live.com/blog/cns!D3543C5837291E93!180.entry) and (http://daniellarson.spaces.live.com/blog/cns!D3543C5837291E93!192.entry). He also covers a handful of watchouts and other concerns.

I hope this helps!

Sean McDonough
This is precisely the sort of thing I was looking for. It even looks pretty simple (or at least, as simple as this sort of thing can get). Thanks!
DivisionByZorro