本文介绍了替换命名空间System.Threading.Timers命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有人,
我正在使用使用System.Timers.Timer命名空间的代码,如下所示:
Dear All,
I am using the code Using System.Timers.Timer namespace as you can see below:
public partial class FilePooling : ServiceBase
{
#region Declarations
private System.ComponentModel.Container components = null;
private System.ServiceProcess.ServiceController serviceController1;
private System.Timers.Timer timer1;
DataTable dtHub = new DataTable();
DataTable dtImage = new DataTable();
#endregion
public FilePooling()
{
InitializeComponent();
this.ServiceName = "FilePooling";
}
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new FilePooling() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
private void InitializeComponent()
{
this.serviceController1 = new System.ServiceProcess.ServiceController();
this.timer1 = new System.Timers.Timer();
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
this.timer1.AutoReset = false;
this.timer1.Enabled = true;
this.timer1.Interval = Convert.ToDouble(ConfigurationSettings.AppSettings["TimerInterval"].ToString());
this.timer1.Elapsed += new System.Timers.ElapsedEventHandler this.timer1_Elapsed);
((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
}
# region timer1_Elapsed
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
timer1.Enabled = true;
FileFTPCopy();
timer1.Enabled = true;
}
}
我想将其替换为Using System.Threading.Timers命名空间.我需要删除System.Timers.Timer.请任何人建议我或编辑该文件,如果psbl .....
问候,
Raj
I want to replace the same with Using System.Threading.Timers namespace. I need to remove the System.Timers.Timer. Plz any one suggest me or edit this if psbl.....
Regards,
Raj
推荐答案
using ThreadTimer = System.Threading.Timers;
在那时,您可以更改以下内容:
At that point you can change this:
System.Threading.Timers.Timer myTimer = new System.Threading.Timers.Timer();
对此:
to this:
ThreadTimer.Timer myTimer = new ThreadTimer.Timer();
这篇关于替换命名空间System.Threading.Timers命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!