C # Bibliotheken für die zeitgesteuerte Aktionen
-
09-10-2019 - |
Frage
tun Sie von irgendwelchen C # -Bibliotheken wissen, dass Sie erlauben eine Reihe von Aktionen zu sequenzieren, dh. jede Aktion ausgeführt wird, wenn die vorherige beendet ist, oder besser noch, nach einem bestimmten Zeitintervall aufgetreten ist.
Danke.
Lösung
Look at http://msdn.microsoft.com/en-us/library/dd537609.aspx
The Task.ContinueWith method let you specify a task to be started when the antecedent task completes.
Example
var task = Task.Factory.StartNew(() => GetFileData())
.ContinueWith((x) => Analyze(x.Result))
.ContinueWith((y) => Summarize(y.Result));
Andere Tipps
for timing try quartz.net. for synchronizing actions, use eg. events, waithandles, Monitor.Wait()
and Monitor.Pulse()
...
otherwise you can handle a set of actions, eg
var methods = new List<Func>
{
FooMethod1,
FooMethod2
}
foreach (var method in methods)
{
method.Invoke();
}
but this only makes sense, if you do not have a moderator-method (sequencial processing) or your methods should not know about each other.
For scheduled tasks you are looking for a library that supports cron jobs. Here is one I used in a project.
http://blog.bobcravens.com/2009/10/an-event-based-cron-scheduled-job-in-c/
A lot of libraries exist. I found many are feature rich and a bit heavy.
Hope this helps.
Bob