I need to update the .Text of a label until the user logs out.
but get this error:
Error: Method name expected
I have listed the code below and the offending line of code is delimited by
//The next line breaks: Error: Method name expected
Thank you,
John Bickmore
+++++++++++++++ +++++++++++++++ ++++++++++
In code behind of footer.aspx
A. Parameters:
1. ctlLabel is an <asp:Label
2. SessionStartTim e is the System.DateTime .Now of when the viewer
logged in
B. In Footer.aspx.cs, the thread is created with:
fFooter myFooter = new fFooter();
myFooter.Update (ctlLabel,Sessi onStartTime);
+++++++++++++++ +++++++++++++++ ++++++++++
using System;
using System.Threadin g;
namespace fFooter
{
/// <summary>
/// Summary Called from Footer.aspx.cs to update the footer with
/// Summary the time in minutes the viewer has been logged in.
/// </summary>
public class fFooter
{
public Thread myThread;
//Parameter(s)
System.DateTime xSessionStartTi me;
public void Update(System.W eb.UI.WebContro ls.Label yLabel, System.DateTime
ySessionStartTi me)
{
xSessionStartTi me = ySessionStartTi me;
//The next line breaks: Error: Method name expected
myThread=new Thread(new ThreadStart(Upd ateLabel(yLabel )));
//The line above breaks: Error: Method name expected
myThread.Start( );
}
private void UpdateLabel(Sys tem.Web.UI.WebC ontrols.Label yLabel)
{
while ( true )
{
yLabel.Text = tTime(xSessionS tartTime);
Thread.Sleep(10 00);
}
}
private string tTime(System.Da teTime xSessionStartTi me)
{
string xx = "Active for: ";
System.DateTime dtBdate = xSessionStartTi me;
System.DateTime dtToday = System.DateTime .Now;
System.TimeSpan tsTotal = dtBdate - dtToday;
decimal xDECIMAL = Convert.ToDecim al(tsTotal.Tota lMinutes * -1);
int xINT = Convert.ToInt32 (decimal.Round( xDECIMAL,0));
if (xINT < 1 )
{
return "Just logged in";
}
else
{
if (xINT == 1)
{
return xx + "1 minute";
}
else
{
return xx + xINT + " minutes";
}
}
}//end of method: tTime
}//end of class: Footer
}//end of Namespace: clsFooter