Re: Threading in C#.Net Web application
- From: "LP" <lp@xxxxx>
- Date: Thu, 31 Mar 2005 11:15:55 -0500
Before delving into threading, read more about underlying technologies of
ASP.NET; specifically HTTP, web server vs. clients browser. It will help you
understand why you can't apply some thing you learned about Windows
programming in a web environment. And why the example you provided is
redicuolos in a web application.
I have seen some "successful" implementation of threading in web
applications, usually when there was a long running task such as long
running sql queries or mass emailing (not spamming). Usually these processes
would take much longer than acceptable in typical web application. A client
browser would make periodic calls to a server checking on the process
progress then updating some html object that resembled a progress bar. These
solutions weren't pretty, programmers have to jump through hoops with clever
mix of client and server side script, often these solutions had unexpected
side effects.
In the end it was decided it's better to optimize SQL queries or have some
kind of batch process that pre-calculates or pre-aggregates data. IMHO use
threading in a web application as the last resort when all other possible
options have been explored.
"Yatharth" <yatharth@xxxxxxxxx> wrote in message
news:ae8d3892.0503310522.2f45a7e2@xxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> I m new to threading and i have successfully runed threading but i
> could display value on my web page ,but its working in code behind
> when i see it through debugger,plzzzzzzz help me here is the code
> below:
>
> i just wana display the simple array value stored in my array variable
> in my textbox thats it.
>
> using System;
> using System.Collections;
> using System.ComponentModel;
> using System.Data;
> using System.Drawing;
> using System.Web;
> using System.Web.SessionState;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.HtmlControls;
> //using MultithreadingApplication.Class ;
> using System.Threading;
> using System.Data.SqlClient;
>
>
>
> namespace MultithreadingApplication
> {
> public class WebForm2 : System.Web.UI.Page
> {
> string strglobal="";
> Object objCust=new Object() ;
> int j=0;
>
>
> protected System.Web.UI.WebControls.Label Label1;
>
>
> private void Page_Load(object sender, System.EventArgs e)
> {
>
> ThreadStart simplest = new ThreadStart(Simplest);
> Thread thread1 = new Thread( simplest ) ;
>
> thread1.Start() ;
>
>
> Label1.Text=strglobal;
>
>
> }
>
> public string GetCustomers()//string city)
> {
> string []str=new string[2] ;
> string strsql="select firstname,lastname from employees";
> SqlConnection conn =new SqlConnection();
> DataSet CustDS =new DataSet();
>
conn.ConnectionString=System.Configuration.ConfigurationSettings.AppSettings
["ConnectionString"];
> SqlCommand commnd=new SqlCommand(strsql,conn);
> SqlDataReader dr ;
> conn.Open();
> dr=commnd.ExecuteReader();
> if(dr.Read())
> {
>
>
> for(int i=0;i<1;i++)
> {
> str[0]=dr["firstname"].ToString() ;
>
> }
>
>
> }
> conn.Close();
> TextBox1.Text =j.ToString() ;
> j++;
>
>
>
> return str[0];
>
> }
>
> public void Simplest()
> {
> TextBox1.Text=strglobal;
>
> for(;;)
> {
> //string i="yy";
> strglobal=GetCustomers();
>
>
> Thread.Sleep(10000) ;
> }
>
> //Console.WriteLine( "Simplest worker - done" ) ;
>
>
> }
>
>
>
>
>
> }
> }
>
>
> Please email me if u anybody have the solution i will be very
> thankful.
>
> Email:Yatharth.Gupta@xxxxxxxxxxxxx
.
- Follow-Ups:
- Re: Threading in C#.Net Web application
- From: yatharth
- Re: Threading in C#.Net Web application
- References:
- Threading in C#.Net Web application
- From: Yatharth
- Threading in C#.Net Web application
- Prev by Date: Re: time static variable value is retained
- Next by Date: Re: Interop - EnumPrintProcessors
- Previous by thread: Re: Threading in C#.Net Web application
- Next by thread: Re: Threading in C#.Net Web application
- Index(es):
Relevant Pages
|
Loading