在窗口服务中使用多线程 [英] use multithreading in window service

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

问题描述

"Windows Service.Service1"的类型初始值设定项在启动窗口服务时引发了异常.

The type initializer for ''Windows Service.Service1'' threw an exception at starting of window service.

推荐答案

从我的角度来看,

创建一个新项目任务",并将其引用到Windows服务.并使用onstart事件在Task项目的类文件中编写代码以创建n个线程.

并且还添加了一些计时器控件以基于时间间隔创建线程.

为了识别上述错误,请在凝视Windows服务的同时尝试编写日志,并保持适当的性能,并尝试在Windows服务中进行捕获.

因为如果Windows服务中出现任何运行时错误,它将停止Windows服务本身.

谢谢
Vijay r
from my point of view,

create a new project "Tasks" and refer it to windows services. and write code to create a n number of thread in class file in the Task project using the onstart event.

and also added some timer control to create the thread based on the time inteval.

for identitfy the above error, try to write a log while staring the windows service and maintain the propery try catch in the windows serivce.

because if you have any runtime error in the windows service, it will stop the windows service itself.

Thanks
Vijay r


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

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