开发者

Asynchronous methods in a webpart

I have been coding for some days on a webpart now. The point of this webpart is to clean up a given document library. I have 16 000+ msg files in there and I have to validate the To and From headers of each msg file against some given rules.

All is well, except for the fact that this process takes forever. All possible values that are allowed in To or From are stored in SPLists in SharePoint itself.

I was able to split the process of validating against the business rules and the webpart itself by calling that specific mail validate method asynchronously.

Now, the technical part where I am a bit lost:

The method returns a Dictionary which I want to bind to a CheckBoxList. So how can I do this? Because I have to wait until my asynchronous m开发者_JAVA技巧ail validate method is done until I can bind the datasource of the CheckBoxList?

My webpart consists actually out of a usercontrol which I load in the webpart.


Have you considered using jQuery/Ajax instead of usercontrols and direct code behind? Thats how I handle asynchronous loading on my webparts, bearing in mind that 99% of our development uses xml/xslt for html generation.


Your async method should call a callback function which continues processing. This callback should do the binding; it only occurs when the async process is done..

Alternatively, with that many items you might still run into problems. Why not create a fully asynchronous process? Your webpart could schedule a run-once timer job in SharePoint which executes your cleanup completely asynchronously. Or record the details of your job in a list which can be picked up by a scheduled executeable or stsadm command extention. This will work with any number of items in your list.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜