Click here to Skip to main content
15,917,808 members
Home / Discussions / C#
   

C#

 
QuestionRe: Datagrid cell double click Pin
Tyler458-Jan-07 4:03
Tyler458-Jan-07 4:03 
AnswerRe: Datagrid cell double click Pin
Mircea Puiu8-Jan-07 21:44
Mircea Puiu8-Jan-07 21:44 
GeneralRe: Datagrid cell double click Pin
Tyler458-Jan-07 22:06
Tyler458-Jan-07 22:06 
QuestionHow do I bookmark code? Pin
mcgahanfl8-Jan-07 3:19
mcgahanfl8-Jan-07 3:19 
AnswerRe: How do I bookmark code? Pin
Mircea Puiu8-Jan-07 3:26
Mircea Puiu8-Jan-07 3:26 
GeneralRe: How do I bookmark code? Pin
mcgahanfl8-Jan-07 5:31
mcgahanfl8-Jan-07 5:31 
AnswerRe: How do I bookmark code? Pin
Pete O'Hanlon8-Jan-07 3:38
mvePete O'Hanlon8-Jan-07 3:38 
QuestionC# Timers Pin
manustone8-Jan-07 3:13
manustone8-Jan-07 3:13 
Hi All
I'm new to C# multithreading and timers.
I've got the code below where I want to prevent the time from repeting itself when the argument passed is not of the string type.

If I uncomment Thread.Sleep(Timeout.Infinite) doesn't work and keeps writing to the console each second when I expected to be stopped.
Why it happens?

Do I have to call tmr.Change(Timeout.Infinit,0) from TimerMethod? This way tmr variable should be shared between the main thread and the thread for the timer and syncrhonization/locking should be involved. Does exist some function to call from TimerMethod from stop itself without referring the Timer object tmr?

Regards
manuStone

class TestTimers
{
public static void TimerMethod(object obj){
if (obj is string) {
String str = (String)obj;
Console.WriteLine(String.Format("Timer by at {0:N6} by {1}", _tmr_cnt, str));
Interlocked.Increment(ref _tmr_cnt);
}
else {
Console.WriteLine("Passed Wrong Argument");
//How to stop the timer here?
//Thread.Sleep(Timeout.Infinite); Doesn't work:why?
//Do I have to call tmr.Change(Timeout.Infinit,0) here?
}
}

public void CallToThread(){
tmr_clbck = new TimerCallback( ThreadFoos.TimerMethod );
tmr = new Timer(tmr_clbck, 5, 0, 1000);
}

private Timer tmr = null;
private TimerCallback tmr_clbck = null;
}
AnswerRe: C# Timers Pin
Mircea Puiu8-Jan-07 3:33
Mircea Puiu8-Jan-07 3:33 
GeneralRe: C# Timers Pin
manustone8-Jan-07 4:10
manustone8-Jan-07 4:10 
QuestionRuning stored procedure with oracle and C# Pin
sdsdsds@hotmail.com8-Jan-07 2:52
sdsdsds@hotmail.com8-Jan-07 2:52 
AnswerRe: Runing stored procedure with oracle and C# Pin
Mircea Puiu8-Jan-07 3:22
Mircea Puiu8-Jan-07 3:22 
GeneralRe: Runing stored procedure with oracle and C# Pin
sdsdsds@hotmail.com9-Jan-07 0:58
sdsdsds@hotmail.com9-Jan-07 0:58 
GeneralRe: Runing stored procedure with oracle and C# Pin
Martin Sp.9-Jan-07 3:53
Martin Sp.9-Jan-07 3:53 
GeneralRe: Runing stored procedure with oracle and C# Pin
sdsdsds@hotmail.com10-Jan-07 1:55
sdsdsds@hotmail.com10-Jan-07 1:55 
GeneralRe: Runing stored procedure with oracle and C# Pin
Martin Sp.10-Jan-07 3:34
Martin Sp.10-Jan-07 3:34 
GeneralRe: Runing stored procedure with oracle and C# Pin
sdsdsds@hotmail.com10-Jan-07 19:36
sdsdsds@hotmail.com10-Jan-07 19:36 
GeneralRe: Runing stored procedure with oracle and C# Pin
Martin Sp.10-Jan-07 23:39
Martin Sp.10-Jan-07 23:39 
GeneralRe: Runing stored procedure with oracle and C# Pin
sdsdsds@hotmail.com14-Jan-07 19:47
sdsdsds@hotmail.com14-Jan-07 19:47 
GeneralRe: Runing stored procedure with oracle and C# Pin
Martin Sp.14-Jan-07 23:57
Martin Sp.14-Jan-07 23:57 
QuestionNew Project Dialog Pin
Rahul.RK8-Jan-07 2:04
Rahul.RK8-Jan-07 2:04 
AnswerRe: New Project Dialog Pin
Mircea Puiu8-Jan-07 3:29
Mircea Puiu8-Jan-07 3:29 
QuestionElegant way to develop a chronometer Pin
AlexB478-Jan-07 1:47
AlexB478-Jan-07 1:47 
AnswerRe: Elegant way to develop a chronometer Pin
Ravi Bhavnani8-Jan-07 2:48
professionalRavi Bhavnani8-Jan-07 2:48 
GeneralRe: Elegant way to develop a chronometer Pin
AlexB478-Jan-07 2:54
AlexB478-Jan-07 2:54 

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.