Click here to Skip to main content
15,913,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: Convert String to Integer Pin
eggie512-Jun-04 19:13
eggie512-Jun-04 19:13 
GeneralRe: Convert String to Integer Pin
Clickok13-Jun-04 5:19
Clickok13-Jun-04 5:19 
GeneralMulti-Styled lable... Pin
mikker_12312-Jun-04 17:48
mikker_12312-Jun-04 17:48 
GeneralRe: Multi-Styled lable... Pin
Heath Stewart12-Jun-04 18:21
protectorHeath Stewart12-Jun-04 18:21 
GeneralRe: Multi-Styled lable... Pin
mikker_12313-Jun-04 3:44
mikker_12313-Jun-04 3:44 
GeneralRe: Multi-Styled lable... Pin
Heath Stewart13-Jun-04 6:30
protectorHeath Stewart13-Jun-04 6:30 
GeneralRe: Multi-Styled lable... Pin
mikker_12313-Jun-04 9:04
mikker_12313-Jun-04 9:04 
GeneralWebRequest.Create method is not thread safe as claimed in MSDN?! Pin
Meysam Mahfouzi12-Jun-04 16:13
Meysam Mahfouzi12-Jun-04 16:13 
I am involved in a project in which I should send bunch of requests(say around 50) to the server all of which are sent to the same domain. So, it's actually much faster to do this job through multi-threading, that is, I give the responsibility of requesting each URL to one separate thread. Requesting all the URLs in a single thread is actually done with no problem, But in multithreaded approach, I encountered some strange exception thrown while creating a WebRequest thru line below:

_URLReq = (HttpWebRequest)WebRequest.Create(_url);
_URLRes = (HttpWebResponse)_URLReq.GetResponse();


this is the exception that I receive:

The remote server returned an error: (403) Forbiddern.


There is no shared resource there, the only thing shared is Create method of WebRequest class which is a static method claimed to be thread safe. I speculated that it's the problem of that method, so I locked it:

lock(typeof(WebRequest))
{
	_URLReq = (HttpWebRequest)WebRequest.Create(_url);
}


but it again didn't work. I locked the next line too:

lock(typeof(WebRequest))
{
	_URLReq = (HttpWebRequest)WebRequest.Create(_url);
	_URLRes = (HttpWebResponse)_URLReq.GetResponse();
}


And that exception never got thrown, the problem was solved. So, what should I say? It really doesn't appear to be thread safe. Any idea? Confused | :confused:
GeneralRe: WebRequest.Create method is not thread safe as claimed in MSDN?! Pin
Heath Stewart12-Jun-04 18:18
protectorHeath Stewart12-Jun-04 18:18 
GeneralRe: WebRequest.Create method is not thread safe as claimed in MSDN?! Pin
Meysam Mahfouzi13-Jun-04 1:57
Meysam Mahfouzi13-Jun-04 1:57 
GeneralVertical text in a DataGrid column header Pin
quilkin12-Jun-04 13:11
quilkin12-Jun-04 13:11 
GeneralRe: Vertical text in a DataGrid column header Pin
Heath Stewart12-Jun-04 18:13
protectorHeath Stewart12-Jun-04 18:13 
GeneralToolbar that doesn't steal focus Pin
David M. Kean12-Jun-04 12:54
David M. Kean12-Jun-04 12:54 
QuestionDll? Pin
SherKar12-Jun-04 12:36
SherKar12-Jun-04 12:36 
AnswerRe: Dll? Pin
Heath Stewart12-Jun-04 18:00
protectorHeath Stewart12-Jun-04 18:00 
GeneralAssemblies in .NET Pin
richard nixon12-Jun-04 10:13
richard nixon12-Jun-04 10:13 
GeneralRe: Assemblies in .NET Pin
Heath Stewart12-Jun-04 10:28
protectorHeath Stewart12-Jun-04 10:28 
Generalunhandled exeption in ListView Pin
Aron Henning12-Jun-04 5:23
Aron Henning12-Jun-04 5:23 
GeneralRe: unhandled exeption in ListView Pin
leppie12-Jun-04 5:41
leppie12-Jun-04 5:41 
GeneralCONTROLLING PROCESSES Pin
_Comet_Keeper_12-Jun-04 4:52
_Comet_Keeper_12-Jun-04 4:52 
GeneralRe: CONTROLLING PROCESSES Pin
Heath Stewart12-Jun-04 5:00
protectorHeath Stewart12-Jun-04 5:00 
GeneralRe: CONTROLLING PROCESSES Pin
_Comet_Keeper_12-Jun-04 10:07
_Comet_Keeper_12-Jun-04 10:07 
GeneralRe: CONTROLLING PROCESSES Pin
Heath Stewart12-Jun-04 10:34
protectorHeath Stewart12-Jun-04 10:34 
GeneralBandwidth usage info Pin
Liskl12-Jun-04 2:19
Liskl12-Jun-04 2:19 
GeneralRe: Bandwidth usage info Pin
Heath Stewart12-Jun-04 4:47
protectorHeath Stewart12-Jun-04 4:47 

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.