Click here to Skip to main content
15,926,857 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to switch off autorun function Pin
Stefan Troschuetz13-Jun-04 5:44
Stefan Troschuetz13-Jun-04 5:44 
GeneralRe: How to switch off autorun function Pin
zlaty13-Jun-04 9:59
zlaty13-Jun-04 9:59 
AnswerRe: How to switch off autorun function Pin
Heath Stewart13-Jun-04 18:15
protectorHeath Stewart13-Jun-04 18:15 
GeneralRe: How to switch off autorun function Pin
zlaty14-Jun-04 4:26
zlaty14-Jun-04 4:26 
GeneralC# Noob in trouble with enumerations Pin
Wingnut7412-Jun-04 20:02
Wingnut7412-Jun-04 20:02 
GeneralRe: C# Noob in trouble with enumerations Pin
David M. Kean12-Jun-04 20:22
David M. Kean12-Jun-04 20:22 
GeneralRe: C# Noob in trouble with enumerations Pin
Daniel Turini12-Jun-04 23:56
Daniel Turini12-Jun-04 23:56 
GeneralRe: C# Noob in trouble with enumerations Pin
Wingnut7413-Jun-04 5:07
Wingnut7413-Jun-04 5:07 
GeneralRe: C# Noob in trouble with enumerations Pin
Cotter13-Jun-04 5:34
Cotter13-Jun-04 5:34 
GeneralRe: C# Noob in trouble with enumerations Pin
Wingnut7413-Jun-04 5:37
Wingnut7413-Jun-04 5:37 
GeneralRe: C# Noob in trouble with enumerations Pin
leppie13-Jun-04 7:06
leppie13-Jun-04 7:06 
GeneralGeneric in C# Pin
vcorn12-Jun-04 19:19
vcorn12-Jun-04 19:19 
GeneralRe: Generic in C# Pin
Stefan Troschuetz12-Jun-04 22:01
Stefan Troschuetz12-Jun-04 22:01 
GeneralRe: Generic in C# Pin
vcorn13-Jun-04 6:18
vcorn13-Jun-04 6:18 
GeneralConvert String to Integer Pin
visitsaadi12-Jun-04 18:35
visitsaadi12-Jun-04 18:35 
GeneralRe: Convert String to Integer Pin
Xiangyang Liu 刘向阳12-Jun-04 19:13
Xiangyang Liu 刘向阳12-Jun-04 19:13 
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 

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.