[Mono-bugs] [Bug 32004][Wis] Changed - Problems with System.Net and threads

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
10 Oct 2002 08:24:30 -0000


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by tapia@eitig.com.

http://bugzilla.ximian.com/show_bug.cgi?id=32004

--- shadow/32004	Wed Oct  9 11:41:46 2002
+++ shadow/32004.tmp.27671	Thu Oct 10 04:24:30 2002
@@ -46,6 +46,60 @@
 
 ------- Additional Comments From dick@ximian.com  2002-10-09 11:41 -------
 Please supply a small self-contained app that demonstrates the
 problem, so I can try and reproduce it.
 
 
+
+------- Additional Comments From tapia@eitig.com  2002-10-10 04:24 -------
+Ok, sorry. Here we go:
+
+using System;
+using System.Net;
+using System.Threading;
+
+public class Class1
+{
+	public string url;
+	public string user;
+	public string passwd;
+	public string host;
+	
+	public void Method1 ()
+	{
+		Thread myThread = new Thread (new ThreadStart(Method2));
+		myThread.Start();
+	}
+	
+	public void Method2 ()
+	{
+		WebRequest request = WebRequest.Create(url);
+		NetworkCredential giveCred = new NetworkCredential(user, passwd, host); 
+		CredentialCache putCache = new CredentialCache(); 
+		putCache.Add(new Uri(url), "Basic", giveCred); 
+		request.Credentials = putCache;
+
+		Console.WriteLine ("No problem");
+		HttpWebResponse response = (HttpWebResponse)request.GetResponse();
+
+		Console.WriteLine ("This will not be written if working with threads");
+	}
+}
+
+public class Class2
+{
+	public static void Main ()
+	{
+		Class1 class1 = new Class1 ();
+		
+		class1.url = "http://www.ximian.com/images/banners/connector.gif";
+		class1.user ="";
+		class1.passwd="";
+		class1.host="www.ximian.com";
+
+		// Without threads
+		class1.Method2();
+
+		// With threads
+		class1.Method1();
+	}
+}