System.Threading.Timer Sample Code (VB.NET)

I consider this to be best practice.

This sample codes requires the knowledge of multi-threading.


1.) It examines two models.

1.1.) Single timer multiple tasks model.

1.2.) Multiple timer objects model.

2.) Reentrancy Issues:

For both model, reentrancy will still happen. In fact, reentrancy cannot be avoided, it can only be mitigated.

2.1.) Try to use system.threading.timers and asynchronous processing. System.timers.timer are more for synchronous processing.

2.2.) Design the program in such that if previous scheduled task is not yet completed, ignore current task schedule and come back later.

3.) CPU Utilization:

Both models have the about the same CPU utilization, with single timer model suffers slightly higher CPU.

The bottleneck is happening at refreshing text at 'System.Windows.Forms.Label'

The more GUI refreshes is made, the high CPU utilization and the slower data gets to be displayed real time.

4.) Benefits of Single Timer Multiple Tasks Model:

Improve manageability, single point of troubleshooting, single point of view.

4.1.) Reduce the possibility of deadlock.

4.2.) Reduce the possibility of exceptions.

5.) Conclusion

5.1 Both models are workable.

5.2 It is not necessary to deploy the single timer multiple tasks model, which will give rise to more bottlenecks and more CPU utilization. Using multiple timer objects proves to be more optimized.

5.3) The most important thing is to mitigate Reentrancy.

Download the (sample code)VB.NET Visual Studio 2008 SP1

Other References:

Also refer to 'System.Timers.Timer Vs System.Threading.Timer'

And 'System.timers.timer hung or hangs'

Comments

Masokis said…
Nice... could i ask something ?
if my attribute is address, which datatype should i use ? usually i use varchar. (i' using mysql db)
Masokis said…
i see.. how about price? i mean data about money..what the prefer datatype? in mysql, i use decimal 11,0. but how about sql server CE ? i just want to decimal place as we use daily (eg:RM2.10)..

i'm still new in .net :)
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
Nice post. I was checking continuously this blog and I'm impressed! Extremely useful information specially the last part :) I care for such information a lot. I was looking for this certain info for a very long time. Thank you and good luck.

Also visit my homepage: pay day loans fast Cash
Anonymous said…
I've been exploring for a bit for any high-quality articles or blog posts in this kind of space . When googling I in due course stumbled upon this web site. Studying this information So i'm haρрy to convey that I've a very excellent uncanny feeling I came upon just what I needed. I most unquestionably will make sure to do not disregard this site and provides it a look regularly.

Feel free to surf to my homepage ... fast online loans
Anonymous said…
What's Taking place i'm nеw to this,
I ѕtumbled upоn this I havе ԁіscovered It absolutely useful and it has aіded me out loads.
I am hoping to gіve а contribution & help оtheг
customers lіκе its aided mе.

Great job.

my web pagе ... Cash Fast
Anonymous said…
Hello therе, јust beсame аlert tо your blοg through
Google, and found that it's truly informative. I am gonna watch out for brussels. I will be grateful if you continue this in future. Numerous people will be benefited from your writing. Cheers!

Feel free to surf to my website - hcg extreme
Anonymous said…
Goοd reaԁ, еspеcially гespοnѕe #4 I think it was.

Worth гemembering.

Also ѵіsit my sіte :: online fast cash loans
Anonymous said…
Seеms liκe mу ρhone has deciԁed
to worκ aѕ it should this time, I cаn actuallу reply.
Јust to sау, I would not do it myself.


Feel free to surf to my blog pоѕt: fast cash advance loan
Anonymous said…
Perfесt shoгt intro, made me rеaԁ it аll.
Mine alwayѕ seem to ωаffle on, yоurѕ iѕ nice and snappy.


Here is my web ѕite ... fast easy payday loan
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
I've seen that many views on this that I could not be more confused.

My web page ... http://www.jobinterviewanswers.biz/2013/01/24/hello-world/?do=basic
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
Copіed in windoωs Vistа аnd then аttempted to paѕtе into
google android. Μaybe I oughtа quit life.



Hеre is my web site - long term loans
Anonymous said…
The figures arе almoѕt ωoгthlеss, meаning the outcоme makeѕ the
least bit of sеnse.

Here iѕ my ѕite: bad credit personal loans
Anonymous said…
Tоԁay's plan - University revision...need to..get some done....

Take a look at my website: best loans
Anonymous said…
This comment has been removed by a blog administrator.