How can I schedule tasks in a WinForms app?

后端 未结 3 576
情书的邮戳
情书的邮戳 2020-12-16 05:17

QUESTION: How can I schedule tasks in a WinForms app? That is either (a) what is the best approach / .NET classes/methods to use of (b) if there is an open source componen

3条回答
  •  天命终不由人
    2020-12-16 05:58

    So you want to run tasks that are predefined code in your app and not external exes?

    • Make a winforms app with a system tray icon. If you are deploying using click once, make the Publisher name "Startup" so a shortcut installs in the Startup directory.

    • Use a timer to check against the schedule and launch threads if needed. Store you local schedule in an XML file so it can be easily queried with LINQ.

    • You are running your tasks with Background worker so threading is already in use.

    If you wanted to use the Windows Task Scheduler however, there is an API for it. Not a graceful module but it works well enough.

提交回复
热议问题