How do I code a Mono Daemon(如何编写 Mono 守护程序)
问题描述
我正在尝试为 linux 编写 Mono C# 守护程序.
I'm trying to write a Mono C# daemon for linux.
我想在它完成处理时启动和停止它,而不是仅仅终止进程.
I'd like to do a starts and stops of it when its done processing instead of just killing the process.
有人有这方面的例子吗?
Does anyone have any examples of this?
我想出了如何在 debian 中使用 start-stop-daemon --background,所以我想我现在就使用它.
I figured out how to use start-stop-daemon --background in debian, so I think I'll just use that for now.
我也在 java 中实现这个,他们有这个很好的 addShutdownHook 可以捕获终止应用程序.我需要花更多的时间来整理单声道服务的依赖关系,或者找到一种方法来捕获应用程序终止.
I'm implementing this in java as well and they have this nice addShutdownHook that catches terminating the app. I need to spend a little more time sorting out the dependencies for mono service, or find a way to catch app termination.
有 SessionEnd 事件,但这仅适用于服务而不是控制台应用程序
There is the SessionEnd event, but thats only available for services and not console apps
答案:在linux上使用mono-service包装一个windows服务
推荐答案
你应该实现一个服务并使用单服务.谷歌一下,你会发现几个例子.
You should implement a service and use mono-service. Google for it and you'll find several examples.
这篇关于如何编写 Mono 守护程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何编写 Mono 守护程序
基础教程推荐
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
