c# 在不同的时间运行2个(或更多)进程?

发布于 2024-09-19 17:15:12 字数 132 浏览 1 评论 0原文

如何在不同的进程中运行不同的任务?

就我而言,我将有 2 个任务,一个任务每 1 分钟运行一次,另一个任务每 10 分钟运行一次,

重点是每个任务都完全独立于另一个任务,

如何使它们在同一个程序中工作?

how to run different tasks in different process?

in my case I will have 2 tasks one runs every 1 mint the other will run every 10 mints

the point is each one is totally independent from the other

how to make them work within the same program?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲欢浪云 2024-09-26 17:15:17

我这样做的方法是创建一个 Windows包含 计时器计时器定期检查是否需要运行每个进程,并在需要运行时使用

  1. ThreadPool 类(如果我认为这就是不同进程的意思)
  2. 一个新的 进程本身。您必须将需要运行的每个函数编译成单独的可执行文件,然后只需使用此类启动它即可。

希望有帮助!

The way I'd do it is to create a Windows Service that contains a Timer. The Timer checks at regular intervals if it is time to run each process, and when it is time to run starts each process using either

  1. The ThreadPool class (if that's what I think you meant by different processes)
  2. A new Process itself. You will have to have each function that needs to run compiled into a seperate executable and then you simply start it using this class.

Hope that helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文