C#中:启动多个连接时,异步委托VS ThreadPool.QueueUserWorkItem [英] C#: Asynchronous delegates vs ThreadPool.QueueUserWorkItem when initiating many connections

查看:162
本文介绍了C#中:启动多个连接时,异步委托VS ThreadPool.QueueUserWorkItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要送很多Web服务调用了删除亚马逊SDB一堆记录(遗憾的是,行只能在一次被删除的一个在当前)。

I have to send many web service calls out to delete a bunch of records in Amazon SDB (unfortunately, rows can only be deleted one at at time currently).

我使用亚马逊的SDB C#库,不使用异步WebRequests。

I am using Amazon's SDB c# library which does not use async WebRequests.

目前我使用ThreadPool.QueueUserWorkItem来排队了一堆电话(我配置我connectionManagement maxconnection允许一堆连接) 这个工程well..as请求被发送出去,它会阻止和另一个请求。

Currently I use ThreadPool.QueueUserWorkItem to queue up a bunch of calls (I configured my connectionManagement maxconnection to allow for a bunch of connections) this works well..as the request is sent out, it blocks and another request is made.

这是错误的方式来实现这一目标?我应该使用异步委托和做的BeginInvoke和EndInvoke?

Is this the wrong way to achieve this goal? Should I be using async delegates and doing BeginInvoke and EndInvoke?

推荐答案

如果你只需要排队一些工作(即不直接返回值)去与 ThreadPool.QueueUserWorkItem 。它的速度更快。的差是覆盖在<一href="http://stackoverflow.com/questions/532791/whats-the-difference-between-queueuserworkitem-and-begininvoke-for-performi">other问题(和一些伟大的博客条目在那里。)

If you just need to queue up some jobs (that don't return values directly) go with ThreadPool.QueueUserWorkItem. It's faster. The difference is covered in other questions (and some great blog entries out there.)

这篇关于C#中:启动多个连接时,异步委托VS ThreadPool.QueueUserWorkItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆