I am writing an application that should do some things in the background: check emails and analyze them to insert some data into the database and connect to the web service to check the status of some asynchronous operations.
Currently, my solution is a simple timer that performs these operations on a predefined schedule: sends an email every five minutes, and the web service checks every minute (but they are executed only in case of pending activity, so most of the time it does nothing .)
Now I do not use a thread for this (I am at the development stage). But my plan is to create a background thread and let it do the work offline.
A couple of questions:
- I plan to control everything in the timer (s). Set up a global variable (rudimentary "lock",) start the flow. If the "lock" is already set, ignore it. The thread cleans it at the end. Should I use a more reliable block / queue mechanism for my threads? (I already have OmniThread installed)
- How to start a thread with a low priority? I do not want the application to look sluggish when the background thread is doing data input or networking.
- Is there a clean way to check user activity and start this thread only when the user is not busy with the keyboard / mouse?
, , . FTP , , .