Click here to Skip to main content
15,920,513 members
Home / Discussions / C#
   

C#

 
AnswerRe: progressbar in a statusbar panel Pin
Heath Stewart22-Sep-05 6:35
protectorHeath Stewart22-Sep-05 6:35 
QuestionInstalling file in Setup Project Pin
Anonymous22-Sep-05 3:38
Anonymous22-Sep-05 3:38 
AnswerRe: Installing file in Setup Project Pin
Heath Stewart22-Sep-05 6:41
protectorHeath Stewart22-Sep-05 6:41 
Questioncheckbox problem Pin
Mridang Agarwalla22-Sep-05 3:34
Mridang Agarwalla22-Sep-05 3:34 
AnswerRe: checkbox problem Pin
KaptinKrunch22-Sep-05 4:29
KaptinKrunch22-Sep-05 4:29 
GeneralRe: checkbox problem Pin
Mridang Agarwalla22-Sep-05 4:43
Mridang Agarwalla22-Sep-05 4:43 
GeneralRe: checkbox problem Pin
Guffa22-Sep-05 6:16
Guffa22-Sep-05 6:16 
Questionhelp in this program Pin
dhol22-Sep-05 3:02
dhol22-Sep-05 3:02 
Hi
I have to do a program in c# windows application such that form employs with a textbox, Progress bar, label and abutton.
I have used system.threading.timer such that , when a time is given in the textbox, (say 02:30 PM),then the progress bar progress and at last after progress bar finishes, the label which is in the form should turn red colour at that specified time(ie, 02:30 PM)..

but, I had a doen a program to such extent that when a time is given in textbox(say 02:30 pm) then the progress bar progresses and finishes soon and the label turns into red colour. Burt not at the specified time(ie, 02:30 pm)..


here is ,my part of coding. Please help me to do the the thing.

private class ThreadRunner
{
private Form1 _form;
private int _delay;
private System.Threading.Timer _timer;

public ThreadRunner(Form1 mainForm,int delayInSeconds)
{
_form=mainForm;
_delay=delayInSeconds;
}

public void Go()
{
// Create a timer passing in a delegate to the TimerElapsedmethod
// null is to be passed as a parameter to Timerelapsed
//0-start immediately
//10--cal a callback everysecond

_timer=new System.Threading.Timer(new TimerCallback (this.TimerElapsed),null,1000,1000);

while (_timer!=null)
Thread.Sleep(0); // Do nothing until timer has stopped

}

public void TimerElapsed(object o)
{
_delay--;
_form.Invoke(new MethodInvoker(_form.UpdateProgress));
if (_delay<=0)
{
_form.Invoke(new MethodInvoker(_form.UpdateLabel));
_timer.Dispose();
_timer=null;
}
}

}



//then inside teh button click
private void button1_Click(object sender, System.EventArgs e)
{
DateTime current = System.DateTime.Now;
DateTime end = DateTime.Parse(textBox1.Text);

TimeSpan ts = end.Subtract(current);

//value entered in the textbox
int timeToRun= System.Convert.ToInt32(ts.Seconds);

//set the maximum range of value

progressBar1.Maximum=timeToRun;
progressBar1.Step=1;
ThreadRunner tr=new ThreadRunner(this,timeToRun);
Thread t=new Thread(new ThreadStart(tr.Go));
t.Start();

}

this is the coding part which i had done.please explain and tell me wher to change and finish it .
dhol
AnswerRe: help in this program Pin
KaptinKrunch22-Sep-05 3:50
KaptinKrunch22-Sep-05 3:50 
Questioncontextmenu Pin
PHDENG8122-Sep-05 2:54
PHDENG8122-Sep-05 2:54 
QuestionGet Primary Display Driver information Pin
pkonaje22-Sep-05 2:33
pkonaje22-Sep-05 2:33 
Questionnotifyicon balloon Pin
g00fyman22-Sep-05 2:19
g00fyman22-Sep-05 2:19 
Answerall fixed Pin
g00fyman22-Sep-05 3:30
g00fyman22-Sep-05 3:30 
QuestionIncremental search Pin
Satish3222-Sep-05 2:14
Satish3222-Sep-05 2:14 
QuestionDELEDTING DATABASE through C# asp.net program ,ms sql database Pin
EKJDBA22-Sep-05 1:50
EKJDBA22-Sep-05 1:50 
AnswerRe: DELEDTING DATABASE through C# asp.net program ,ms sql database Pin
Colin Angus Mackay22-Sep-05 2:24
Colin Angus Mackay22-Sep-05 2:24 
Questioncan't load ruleml into dataset Pin
pramod.21c22-Sep-05 1:40
pramod.21c22-Sep-05 1:40 
AnswerRe: can't load ruleml into dataset Pin
Dave Kreskowiak22-Sep-05 5:24
mveDave Kreskowiak22-Sep-05 5:24 
QuestionCheck if user has admin rights Pin
Stefan_ Spenz22-Sep-05 1:24
Stefan_ Spenz22-Sep-05 1:24 
QuestionExplain DataSet.AcceptChanges and DataAdapter.Update methods. Pin
webC#22-Sep-05 1:17
webC#22-Sep-05 1:17 
AnswerRe: Explain DataSet.AcceptChanges and DataAdapter.Update methods. Pin
Ming Luo22-Sep-05 2:01
Ming Luo22-Sep-05 2:01 
AnswerRe: Explain DataSet.AcceptChanges and DataAdapter.Update methods. Pin
kundan.apiit15-Apr-12 4:19
kundan.apiit15-Apr-12 4:19 
QuestionLockout Pin
mikica1722-Sep-05 1:17
mikica1722-Sep-05 1:17 
AnswerRe: Lockout Pin
Guffa22-Sep-05 1:36
Guffa22-Sep-05 1:36 
GeneralRe: Lockout Pin
mikica1722-Sep-05 2:09
mikica1722-Sep-05 2:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.