... I need peace
This commit is contained in:
parent
77e229fc8a
commit
b998c94f51
47 changed files with 2034 additions and 11979 deletions
78
cli/YaTaskScheduler.cs
Normal file
78
cli/YaTaskScheduler.cs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YaDaemon
|
||||
{
|
||||
public class YaTaskScheduler : TaskScheduler
|
||||
{
|
||||
List<Task> _tasks;
|
||||
|
||||
protected override IEnumerable<Task> GetScheduledTasks()
|
||||
{
|
||||
return _tasks;
|
||||
}
|
||||
|
||||
protected override void QueueTask(Task task)
|
||||
{
|
||||
_tasks.Add(task);
|
||||
}
|
||||
|
||||
protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
|
||||
{
|
||||
task.Start();
|
||||
task.Wait();
|
||||
return task.IsCompleted;
|
||||
}
|
||||
}
|
||||
public class YaDaemon: IDisposable
|
||||
{
|
||||
|
||||
private readonly EventLog _log =
|
||||
new EventLog("Application") { Source = "Application" };
|
||||
|
||||
async void MainLoop(string[] args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
async Task StartAsync(string[] args)
|
||||
{
|
||||
await Task.Run(() => {
|
||||
OnStart(args);
|
||||
} );
|
||||
}
|
||||
|
||||
protected void OnContinue()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void OnShutdown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void OnStart(string[] args)
|
||||
{
|
||||
_log.WriteEntry("Test from YaDaemon.", EventLogEntryType.Information, 1);
|
||||
_log.WriteEntry("YaDaemon started.");
|
||||
Console.WriteLine("YaDaemon started");
|
||||
}
|
||||
|
||||
protected void OnStop()
|
||||
{
|
||||
_log.WriteEntry("YaDaemon stopped.");
|
||||
Console.WriteLine("YaDaemon stopped");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue