Click here to Skip to main content
16,016,024 members
Home / Discussions / C#
   

C#

 
Generalanalyzing a string Pin
Anonymous26-Oct-04 20:32
Anonymous26-Oct-04 20:32 
GeneralRe: analyzing a string Pin
sreejith ss nair26-Oct-04 22:20
sreejith ss nair26-Oct-04 22:20 
GeneralRe: analyzing a string Pin
Colin Angus Mackay26-Oct-04 22:22
Colin Angus Mackay26-Oct-04 22:22 
GeneralListView ScrollBar Pin
Zishan Haider26-Oct-04 19:50
Zishan Haider26-Oct-04 19:50 
GeneralRe: ListView ScrollBar Pin
sreejith ss nair26-Oct-04 22:16
sreejith ss nair26-Oct-04 22:16 
GeneralRe: ListView ScrollBar Pin
Zishan Haider26-Oct-04 22:34
Zishan Haider26-Oct-04 22:34 
GeneralTimeout in WebRequest.GetRequestStram() Pin
Guillermo Jimenez26-Oct-04 15:43
Guillermo Jimenez26-Oct-04 15:43 
GeneralRe: Timeout in WebRequest.GetRequestStram() Pin
Heath Stewart26-Oct-04 17:20
protectorHeath Stewart26-Oct-04 17:20 
Are you closing your connections? The number 5 seems almost programmed, like that's a connection limit. You need to make sure that you close your connections by calling Close or, better yet, use the using block statement to make sure the HttpWebResponse gets disposed (which closes the connection among other things):
using (HttpWebResponse response =
  (HttpWebResponse)request.GetResponse())
{
  // Read from response. When execution exits the block or an
  // exception is thrown (a variant of the latter case), the response
  // is still disposed.
}
The using block statement compiles to a try-finally block, where it is disposed - if not null - in the finally block (so exceptions are thrown but the finally block is always executed before execution returns to the caller).

Now, if you need to allocate N number of connections like a web crawler or something, you need to control your threads. Don't just create new threads when you feel you have to. Using the ThreadPool helps in these case.

The .NET BCL also includes checks to prevent too many stops. This uses a ServicePointManager and the ServicePoint classes to limit connections. The ServicePointManager.DefaultConnectionLimit gets or sets the default number of connections. Setting that higher may help, but most servers implement their own connection limits.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: Timeout in WebRequest.GetRequestStram() Pin
Guillermo Jimenez27-Oct-04 16:40
Guillermo Jimenez27-Oct-04 16:40 
GeneralRe: Timeout in WebRequest.GetRequestStram() Pin
Heath Stewart27-Oct-04 22:08
protectorHeath Stewart27-Oct-04 22:08 
GeneralParser class for an Interpreter Pin
Member 138504926-Oct-04 15:06
Member 138504926-Oct-04 15:06 
GeneralRe: Parser class for an Interpreter Pin
LongRange.Shooter26-Oct-04 16:28
LongRange.Shooter26-Oct-04 16:28 
GeneralRe: Parser class for an Interpreter Pin
Heath Stewart26-Oct-04 17:23
protectorHeath Stewart26-Oct-04 17:23 
QuestionSite crawling/spidering tutorial? Pin
Justin Garrick26-Oct-04 13:48
Justin Garrick26-Oct-04 13:48 
AnswerRe: Site crawling/spidering tutorial? Pin
Nick Parker26-Oct-04 16:59
protectorNick Parker26-Oct-04 16:59 
AnswerRe: Site crawling/spidering tutorial? Pin
Heath Stewart26-Oct-04 17:12
protectorHeath Stewart26-Oct-04 17:12 
GeneralExcel Program DLL's Pin
Jeremy Ouellette26-Oct-04 13:02
Jeremy Ouellette26-Oct-04 13:02 
GeneralRe: Excel Program DLL's Pin
Heath Stewart26-Oct-04 13:40
protectorHeath Stewart26-Oct-04 13:40 
GeneralVisual Studio Add-In Pin
Nxsis26-Oct-04 12:05
Nxsis26-Oct-04 12:05 
GeneralRe: Visual Studio Add-In Pin
Heath Stewart26-Oct-04 13:01
protectorHeath Stewart26-Oct-04 13:01 
GeneralPictureBox help! Pin
ethanwa26-Oct-04 11:33
ethanwa26-Oct-04 11:33 
GeneralRe: PictureBox help! Pin
Heath Stewart26-Oct-04 12:44
protectorHeath Stewart26-Oct-04 12:44 
GeneralRe: PictureBox help! Pin
Nick Parker26-Oct-04 13:11
protectorNick Parker26-Oct-04 13:11 
GeneraluserAccountControl problem Pin
Zackmac26-Oct-04 10:16
Zackmac26-Oct-04 10:16 
GeneralRe: userAccountControl problem Pin
Heath Stewart26-Oct-04 10:23
protectorHeath Stewart26-Oct-04 10:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.