Re: Threading in C#.Net Web application



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


.



Relevant Pages

  • Re: Application design
    ... I have never done a queue based system (and also done very little in the way ... server or clustered web server etc.) However, ... customer and each customer will have a 'priority' preference, ... I guess I should be doing threading here (I have not really done any ...
    (microsoft.public.dotnet.framework)
  • Re: python - dll access (ctypes or swig)
    ... written my COM servers as .EXE files even though they cannot be run ... .EXE of my COM server and after I register it, ... and some technical issues such as threading (if COM client and server ... their threading models are independent from ...
    (comp.lang.python)
  • Re: How do I trun off casini web server?
    ... you may also need to switch to a multiproc machine to detect threading ... Under Server, click "Use custom server". ... server, but when I publish it to the web, which is using IIS (ASP.NET ... I cannot figure out how to switch my dev environment back to IIS so I can ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Genes Server Down?
    ... |> considered thoughts to the readers of rec.boats: ... |> |> Rec.boats at Lee Yeaton's Bayguide ... |threading on some other server just to compare? ...
    (rec.boats)
  • Re: InvalidCastException Using AzMan from ASP.NET
    ... threading model mismatch or permmision denied. ... To configure your ASP.NET application server to run in a service ... security context of the service account created for the application server. ... Microsoft Internet Information Services page on the Microsoft Web site at ...
    (microsoft.public.dotnet.framework.interop)

Loading