What is the best practice for setting up a background process that runs every 10 minutes in a WinForm project? Is it to use a backgroundworker off of the form? Or is there a more generic way that would apply to many more project styles?
Maybe some code I should call right before the line:
Application.Run(new Form1());
Typically, if you want a Windows Forms application to run some code on a regular interval, using a Windows.Forms.Timer on one of your forms is an appropriate way to handle the notifications.
However, as you seem to have realized, this will require you to have a form up and running, and tie you to the Windows Forms infrastructure.
Another, alternative, approach would be to use a System.Threading.Timer class, which notifies you on a background thread. However, if you use this approach, you’ll need to use some form of synchronization if you want your “process” to interact with the user interface. The best platform neutral approach (works with Windows Forms + WPF) would be to use SyncrhonizationContext to marshal back to the UI thread, if required.