Threads on leaving the asp.net pagehttp://forums.asp.net/t/674524.aspx/1?Threads+on+leaving+the+asp+net+pageTue, 24 Aug 2004 15:00:06 -0400674524674524http://forums.asp.net/p/674524/674524.aspx/1?Threads+on+leaving+the+asp+net+pageThreads on leaving the asp.net page <b>Edited by SomeNewKid. Please post code between &lt;code&gt; and &lt;/code&gt; tags.</b> <hr> Hallo, I have 2 IIS Server. On both i have a asp.net script. The first script on the first server connects to the second script on the second server ba an HttpWebRequest-objects. The second asp.net-script sends the xml-answer by Response.Write(). My problem is now that i have to get a thread doing more work after the second script has ended. So before the end of the second script i instanciate a new Thread by a own c#-class. <pre class="prettyprint">ResponseRequester responseRequester = new ResponseRequester(); responseRequester.setAbsolutePath(Server.MapPath(&quot;.&quot;)); responseRequester.setURL(url); responseRequester.confirm();</pre> The class starts the Thread: <pre class="prettyprint">using System; using System.Collections; using System.Threading; using System.Xml; namespace tinasimulator { /// <summary> /// Summary description for ResponseRequester. /// </summary> public class ResponseRequester { /// <summary> /// The url to send the request to. /// </summary> private string url = ""; private Thread confirmer = null; private string absolutePath = ""; public ResponseRequester() { } public void setAbsolutePath(string absolutePath) { this.absolutePath = absolutePath; } ///<summary> ///Sets the url to connect to. ///</summary> public void setURL(String url) { this.url = url; } ///<summary> ///start the thread to connect to the tinasimulator. ///</summary> public void confirm() { try { this.confirmer = new Thread(new ThreadStart(this.send)); this.confirmer.Name = "confirmer"; this.confirmer.Priority = ThreadPriority.Highest; this.confirmer.Start(); Logger.log("Thread started"); } catch(Exception e) { Logger.log(e.ToString()); } } public void send() { Thread.sleep(5000); //read the server data from a file ConfigLoader configLoader = new ConfigLoader(); Hashtable config = configLoader.loadConfig //send the request ServerConnector serverConnector = new ServerConnector(); string requestEndXML = "<?xml version=\"1.0\" ?>......"; XmlDocument requestEndXMLDocument = new requestEndXMLDocument.LoadXml(requestEndXML); serverConnector.sendRequest(requestEndXMLDocument, url, (String) config["user"], (String) config["password"]); } } }</pre> The class Server connector connects to another server. I can't do it in another way - sorry. So my problem is that after the page is left the thread crashes. VS.NET2003 says: &quot;An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module. Additional information: Object reference not set to an instance of an object.&quot; So what i am doing wrong to get the thread be alive after the page is over? Thanks for any help. 2004-08-24T14:43:43-04:00