开发者

WP7 vs PriorityThreadPool & Network Action

开发者 https://www.devze.com 2023-02-22 09:54 出处:网络
I’m building a small WP7 app that need to access/update several resource over the web. I’m looking to build a PriorityThreadPool object with some cancellation feature to help me running “Action” o

I’m building a small WP7 app that need to access/update several resource over the web. I’m looking to build a PriorityThreadPool object with some cancellation feature to help me running “Action” on several Thread on the background. Well the custom thing download in priority开发者_StackOverflow社区 what the user is seeing then download the rest but if the user update the visual then change the priority and make those item appear upper in the propriety list of the pool.

Let’s say I’m implementing an action responsible to download an Image from a web server would you try to make the Async call sync or will you just leave it as is, please take in consideration that I may run 100 action that download 100 different image. Perhaps If I do not make the call sync It will be pretty difficult to cancel an action since they will all run pretty fast in the thread pool. I guess that under the hood there some sort of thread pool for the network connectivity on WP7

Any comments or suggestion.


Rather than try and (re?)create a "PriorityThreadPool" I'd create an object which manages multiple queues which you can adjust the priority of as necessary.
This could then process each queue depending upon priority.
When processing the queue, only issue a few requests at once and start the next when one finishes.

You could do the processing on the ThreadPool or by creating a BackgroundWorker if you want greater control over being able to cancel requests.

Within each request you may want to process it as a synchronous operation as it will make the logic simpler but will make cancelling things harder.

0

精彩评论

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