your local server Hey guys, I'm trying to get threading to work in ASP.NET, but Due to this, it keeps crashing, and simply does not work when uploaded online.
protected void testThread () {(int i = 0; i & LT; 10; i ++) to Lt & the {Response.Write ( "Threading; br / & gt;
"); Thread.Sleep (500); }} Secure Zero Button 1_Click (Object Sender, EventArgs E) {Thread oThread = NewTrread (testThread); OThread.Priority = ThreadPriority.Lowest; // Try it without and start / thread thread otread.start (); } Any ideas? The
Like what @Daniel said, Response already your thread The time may be expired, its solution is to keep the connection alive, while the thread runs. We want can tell and what to work with Asynchronous work protected void Page_Load (object sender, EventArgs e) {AddOnPreRenderCompleteAsync (New BeginEventHandler (Thread_BeginEvent), New EndEventHandler (Thread_EndEvent )). } Secure Override Zero OnPreRender (EventArgs e) {base.OnPreRender (E); Response.Write (results); } Private string result; IAsyncResult Thread_BeginEvent (object sender, EventArgs e, AsyncCallback cb, Object extraData) {WaitCallback w = new WaitCallback (Thread_DoWork); Return w.BeginInvoke (Sender, CB, Additional Data, W); } Zero Thread_EndEvent (IAsyncResult AR) {WaitCallback w = ar.AsyncState as WaitCallback; If (w! = Null) w.EndInvoke (AR); } Zero Thread_DoWork (Object Position) {Results = ""; For (int i = 0; i & lt; 10; i ++) {Results = + "Threading k
<; br / & gt; & lt; br / & gt; Thread.Sleep (500); }} You can also try it, although I'm not sure whether it works or not, but I suspect it will be:
< code> zero Thred_ DoWork (object state) {for (int i = 0; i & lt; 10; i ++) {Response.Write ( "threading! & Lt; br / & gt; & lt; br / & gt; "); Thread.Sleep (500); }}
Comments
Post a Comment