Click here to Skip to main content
16,016,391 members
Home / Discussions / C#
   

C#

 
AnswerRe: Which Timer to use? Pin
Paladin20004-Feb-11 4:10
Paladin20004-Feb-11 4:10 
GeneralRe: Which Timer to use? Pin
Ravi Sant4-Feb-11 9:42
Ravi Sant4-Feb-11 9:42 
AnswerRe: Which Timer to use? Pin
Pete O'Hanlon4-Feb-11 4:21
mvePete O'Hanlon4-Feb-11 4:21 
GeneralRe: Which Timer to use? Pin
Ian Shlasko4-Feb-11 6:05
Ian Shlasko4-Feb-11 6:05 
GeneralRe: Which Timer to use? Pin
Pete O'Hanlon4-Feb-11 9:30
mvePete O'Hanlon4-Feb-11 9:30 
GeneralRe: Which Timer to use? Pin
Ian Shlasko4-Feb-11 10:37
Ian Shlasko4-Feb-11 10:37 
AnswerRe: Which Timer to use? Pin
PIEBALDconsult4-Feb-11 4:41
mvePIEBALDconsult4-Feb-11 4:41 
AnswerRe: No demons to be seen Pin
Luc Pattyn4-Feb-11 6:04
sitebuilderLuc Pattyn4-Feb-11 6:04 
your first concern should be: do I want those operations on the GUI thread, or anywhere but the GUI thread? Having it in a separate thread right now points to the latter. So a Windows.Forms.Timer would be wrong as that one ticks on the GUI thread, all other timers could be fine.

Of course, the operations not running on the GUI thread also means you need InvokeRequired/Invoke if your updated data needs to become visible on the GUI, and having multiple threads (or non-GUI timers) requires attention to synchronization.

A secondary concern could be how much control you need on the actual thread the operations will be running. A timer would tick on a ThreadPool thread, and you would have no say in its priority, nor would you be able to abort it, if you were so inclined; ditto for a BackgroundWorker. A regular thread (an instance of the Thread class) would offer you full control.

One final remark: a timer tends to set a target for periodicity, it is the time span between the beginning of two consecutive events; a Thread.Sleep() sets a gap, typically from the end of one action to the beginning of another. This difference most often is irrelevant, it may cause the actual period to be slightly larger.

Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

Questionshow form Pin
Elham M4-Feb-11 3:09
Elham M4-Feb-11 3:09 
AnswerRe: show form Pin
Pete O'Hanlon4-Feb-11 3:23
mvePete O'Hanlon4-Feb-11 3:23 
AnswerRe: show form Pin
Paladin20004-Feb-11 4:03
Paladin20004-Feb-11 4:03 
GeneralRe: show form Pin
Elham M5-Feb-11 5:46
Elham M5-Feb-11 5:46 
GeneralRe: show form Pin
Paladin20007-Feb-11 3:37
Paladin20007-Feb-11 3:37 
GeneralRe: show form Pin
Elham M7-Feb-11 6:21
Elham M7-Feb-11 6:21 
AnswerRe: show form Pin
freshonlineMax4-Feb-11 4:04
freshonlineMax4-Feb-11 4:04 
GeneralRe: show form Pin
Pete O'Hanlon4-Feb-11 4:16
mvePete O'Hanlon4-Feb-11 4:16 
AnswerRe: show form Pin
_Erik_4-Feb-11 5:32
_Erik_4-Feb-11 5:32 
AnswerRe: show form Pin
DaveyM694-Feb-11 6:23
professionalDaveyM694-Feb-11 6:23 
AnswerRe: show form Pin
Anubhava Dimri4-Feb-11 21:34
Anubhava Dimri4-Feb-11 21:34 
Questionchange the shape of the tab header in tab control Pin
NarVish4-Feb-11 1:39
NarVish4-Feb-11 1:39 
AnswerRe: change the shape of the tab header in tab control PinPopular
Luc Pattyn4-Feb-11 2:06
sitebuilderLuc Pattyn4-Feb-11 2:06 
GeneralRe: change the shape of the tab header in tab control Pin
NarVish6-Feb-11 17:41
NarVish6-Feb-11 17:41 
GeneralRe: change the shape of the tab header in tab control Pin
Luc Pattyn6-Feb-11 21:15
sitebuilderLuc Pattyn6-Feb-11 21:15 
Questionc# Client Server Application Pin
LAPEC4-Feb-11 1:35
LAPEC4-Feb-11 1:35 
AnswerRe: c# Client Server Application Pin
RobCroll4-Feb-11 1:49
RobCroll4-Feb-11 1:49 

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.