开发者

C# What is my best option? Service/Application/Multiple Applications [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
开发者_运维百科

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 5 years ago.

Improve this question

I am developing a solution that requires a number of tasks to be completed at various times. Example:

  • Task 1 - Monitor mailbox, process mail items
  • Task 2 - Monitor mailbox (different folder), process mail items
  • Task 3 - Generate PDF reports
  • Task 4 - Monitor folder, distribute files via email as attachments when new ones arrive.

I have already implemented the solution, however, it was basically just a quick fix to get the thing running. Now that it is up, I want to revisit the current setup and improve it so it is as efficient as possible.

For the current solution I have created a sepearate application for each different task and used the Task Scheduler to execute them at specific times.

  • Task 1 is a console application that runs on a scheduled task every 5 minutes
  • Task 2 is a console application that runs on a scheduled task every 5 minutes (2 minutes after the first application this is because Task 1 will move emails into the folder Task 2 is monitoring)
  • Task 3 is run at 5am every day as a runonce application on a scheduled task
  • Task 4 is running indefinetly.

My question is, does this seem like a reasonable approach for a solution to this type of application? Do some of the tasks seem better as a service rather than an application?


I think I'd probably use a single service which can be easily configured to run the various tasks (so that if you want to separate them later, you can do so).

Scheduling specific applications is okay and certainly a simpler way of working, but this feels more like a service to me. Of course, if you separate out the "doing stuff" logic from the "invocation" side of things, you can easily switch from one to the other.

The efficiency side of things is unlikely to change much by this decision. Do you have good grounds to be worried about the overall efficiency at the moment? Have you profiled your applications to work out where any bottlenecks are? I'd say they're unlikely to be in the scheduling side of things.


A service sounds like the right way to approach this.

Long running subtasks such as PDF generation are well suited to perform using the asynchronous programming method, i.e. using worker threads that call back to the parent thread upon completion. This way the monitor tasks can run independently of the action tasks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜