在Windows服务中使用System.Timers.Timer [英] Using System.Timers.Timer in Windows service

查看:89
本文介绍了在Windows服务中使用System.Timers.Timer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的大家,
任何人都可以向我解释有关在Windows服务中使用System.Timers.Timer的情况. 我想知道命名空间" System.Timers的使用和好处..
请尽可能举一些例子

问候,
Raj

Hi Dear All,
Can anyone please explain me about Using System.Timers.Timer in Windows service..?
I want to know the use and benefits of the "namespace" System.Timers..
Plz give some examples if possible

Regards,
Raj

推荐答案

没有什么可解释的.好处……与什么相比呢?
阅读并使用帮助.我看不到您可以在哪里遇到任何问题,但是当您遇到问题时,再问一个问题.

我的问题是:为什么要完全使用计时器?通常,使用线程更加健壮和容易.考虑到这一事实,Windows Service无论如何都需要创建线程,为什么不使用额外的线程(可能在System.Threading.Thread.Sleep中进行计时).一般建议是:如果有机会避免使用任何计时器,请使用它.

—SA
There is nothing to explain. Benefits… compared to what?
Read help and use it. I don''t see where you can face any problem, but when you do, ask another Question.

My question is: why using a timer at all? Usually, using threads is much more robust and easy. Considering the fact, that Windows Service will require creation of threads anyway, why not using an extra thread (possible with System.Threading.Thread.Sleep for timing). The general recommendation is: if you have any opportunity to avoid using any timers, use it.

—SA


这篇关于在Windows服务中使用System.Timers.Timer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆