使用windows控制台调试服务的方法
时间:2023-08-19 03:34:30
将Program类的删除,将里面的静态类Main修改后放入服务类中:
partial class Server1 : ServiceBase
{
public Server1()
{
InitializeComponent();
}
/// <summary>
/// 应用程序的主入口点。
/// </summary>
static void Main(string[] args)
{
Server1 sv = new Server1();
if (args.Length > 0)
{
sv.OnStart(args);
char c;
while ((c = Convert.ToChar(Console.Read())) != 'q')
if (c == 'g') GC.Collect();
sv.OnStop();
Console.ReadLine();
}
else
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
sv
};
ServiceBase.Run(ServicesToRun);
}
}
protected override void OnStart(string[] args)
{
}
protected override void OnStop()
{
}
}
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Spring框架中一个有用的小组件之Spring Retry组件详解
原生Java操作兔子队列RabbitMQ
![](https://img.aspxhome.com/file/2023/9/70559_0s.png)
Android中初始化Codec2的具体流程
![](https://img.aspxhome.com/file/2023/0/137580_0s.jpg)
Java模拟计算机的整数乘积计算功能示例
![](https://img.aspxhome.com/file/2023/8/75678_0s.png)
Unity Shader实现序列帧动画效果
![](https://img.aspxhome.com/file/2023/5/77225_0s.png)
java多线程Future和Callable类示例分享
C#实现GZip压缩和解压缩入门实例
C#统计字符串里中文汉字个数的方法
C#中dotnetcharting的用法实例详解
![](https://img.aspxhome.com/file/2023/8/106508_0s.png)
Flutter Navigator路由传参的实现
Android源码 在Ubuntu上下载,编译和安装
![](https://img.aspxhome.com/file/2023/7/139057_0s.jpg)
详解如何全注解方式构建SpringMVC项目
![](https://img.aspxhome.com/file/2023/6/116806_0s.png)
C#和JavaScript实现交互的方法
判断图片-判断位图是否是黑白图片的方法
Android 使用 okhttp3和retrofit2 进行单文件和多文件上传
![](https://img.aspxhome.com/file/2023/5/135605_0s.png)
解决java文件流处理异常 mark/reset not supported问题
![](https://img.aspxhome.com/file/2023/8/81228_0s.jpg)
Android使用插件实现代码混淆
![](https://img.aspxhome.com/file/2023/3/137753_0s.jpg)
C# log4net 日志输出的实现示例
![](https://img.aspxhome.com/file/2023/8/85698_0s.png)
listView的item中有checkbox,导致setOnItemClick失效的原因及解决办法
C#实现Array添加扩展实例
![](https://img.aspxhome.com/file/2023/2/74822_0s.png)