I'm wondering what the easiest method to write a credit card applicatoin could be. Essentially, I've got a sports simulation project that's multi-threaded and may execute different game simulations at the same time.
I store my matches inside a SQLite database which have a DateTime mounted on it.
I wish to write a credit card applicatoin that inspections every hour approximately to ascertain if any new matches have to be performed and spawns individuals threads off.
I can not depend around the task scheduler to complete this every hour because you will find objects the different cases of that process would share (particularly a competitive sport object), which i suspect could be overwritten with a more recent process when saved into the DB. So ideally I have to write some kind of lengthy-running procedure that sleeps between hrs.
I have written my object model to ensure that each object is just loaded once from memory, in order lengthy as all simulation threads are created from that one application, they should not be overwriting data.
EDIT: More detail on needs
Essentially, multiple matches have to have the ability to run at the same time. These matches could be of arbitrary length, so you no longer need that certain finishes prior to the other starts (actually, generally you will see multiple matches performing simultaneously).
What I am picturing is really a program that runs without anyone's knowledge (something, I suppose?) that sleeps for an hour after which inspections the database to ascertain if any games ought to be began. If you will find any to become began, it fires off threads to simulate individuals games after which dates back to rest. Hence, the simulation threads are running however the "arranging" thread is sleeping for an additional an hour.
The main reason I can not (I believe) make use of the default OS task-arranging interface is the fact that these require task to become performed to become spurned like a new process. I've developed my database object model such that they're cached by each object class on first load (the memory reference) and therefore each object is just loaded from memory once which reference can be used on all saves. And therefore when each simulation thread is performed and saves off its condition, exactly the same reference can be used (with up-to-date condition) in order to save from the condition. If your different executable is released each time, most probably another memory reference is going to be opened up by each process and therefore one process could save in to the DB and overwrite the condition compiled by another process.
Something appears like what you want. It is possible to way to create a service just sleep for an hour and awaken and perform function next? I seem like causeing this to be a typical console application would waste memory, but I'm not sure if there's a competent method of doing what I am unaware of.
If you wish to allow it to be really reliable, turn it into a Service.
However I aren't seeing any problems in which makes it an ordinary (Console, WinForms, WPF) application.
You may could expand around the needs just a little.