有关windows服务的问题 windows服务中OnStart(string args)中的参数怎么传递,劳驾,急!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用 OnStart 指定服务收到“开始”命令时进行的处理。OnStart 是您在其中指定服务行为的方法。OnStart 能以参数作为传递数据的方式,但这种用法很少见。不要使用构造函数执行应在 OnStart 中进行的处理。使用 OnStart 处理服务的所有初始化。构造函数在应用程序的可执行文件运行(而不是在服务运行)时调用。可执行文件在 OnStart 之前运行。例如,当继续服务时,不会再次调用构造函数,因为 SCM 已在内存中保存了该对象。如果 OnStop 释放在构造函数(而不是 OnStart)中分配的资源,则第二次调用服务时不会再次创建所需资源。 服务可以设置为在计算机重新启动时启动,方法是在服务的安装程序上设置 StartType。在此类情况下,会在系统启动时调用 OnStart。应在派生类中重写 OnStart。要使服务可用,应在服务类中将 OnStart 和 OnStop 都实现。 // Start the service. protected override void OnStart(string[] args) { IntPtr handle = this.ServiceHandle; myServiceStatus.currentState = (int)State.SERVICE_START_PENDING; SetServiceStatus(handle, myServiceStatus); // Start a separate thread that does the actual work. if ((workerThread == null) || ((workerThread.ThreadState & (System.Threading.ThreadState.Unstarted | System.Threading.ThreadState.Stopped)) != 0)){ workerThread = new Thread(new ThreadStart(ServiceWorkerMethod)); workerThread.Start(); } myServiceStatus.currentState = (int)State.SERVICE_RUNNING; SetServiceStatus(handle, myServiceStatus); } 如何编写配置文件管理器 生产水印居中。。 C#报表的问题 哪儿有C#写的winform框架,开源的 c#打印自定义纸型和固定纸型 用本类的构造方法创建对象 与 用其他类的普通方法创建的对象 有什么区别? 如何从Form1窗口获取Form2的查询 界面设计的探讨问题. 求一份VS c# 2005用serialport类收发短信的实例,非常感谢 存储过程中用游标出现的问题 一个有关SWITCH(Something.gettype())的问题 关于oledb操作excel
不要使用构造函数执行应在 OnStart 中进行的处理。使用 OnStart 处理服务的所有初始化。构造函数在应用程序的可执行文件运行(而不是在服务运行)时调用。可执行文件在 OnStart 之前运行。例如,当继续服务时,不会再次调用构造函数,因为 SCM 已在内存中保存了该对象。如果 OnStop 释放在构造函数(而不是 OnStart)中分配的资源,则第二次调用服务时不会再次创建所需资源。
服务可以设置为在计算机重新启动时启动,方法是在服务的安装程序上设置 StartType。在此类情况下,会在系统启动时调用 OnStart。应在派生类中重写 OnStart。要使服务可用,应在服务类中将 OnStart 和 OnStop 都实现。 // Start the service.
protected override void OnStart(string[] args)
{
IntPtr handle = this.ServiceHandle;
myServiceStatus.currentState = (int)State.SERVICE_START_PENDING;
SetServiceStatus(handle, myServiceStatus); // Start a separate thread that does the actual work. if ((workerThread == null) ||
((workerThread.ThreadState &
(System.Threading.ThreadState.Unstarted | System.Threading.ThreadState.Stopped)) != 0)){ workerThread = new Thread(new ThreadStart(ServiceWorkerMethod));
workerThread.Start();
}
myServiceStatus.currentState = (int)State.SERVICE_RUNNING;
SetServiceStatus(handle, myServiceStatus); }