89 lines
1.8 KiB
C#
89 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Concurrent;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Diagnostics;
|
|
using Mono.Options;
|
|
|
|
|
|
namespace EventPump
|
|
{
|
|
class Program
|
|
{
|
|
|
|
|
|
static void Main(string[] args)
|
|
{
|
|
|
|
|
|
Console.WriteLine("Press Enter");
|
|
Console.ReadLine();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
class EventCollector
|
|
{
|
|
volatile bool RunCollect = true;
|
|
ConcurrentQueue<EventLog> events = new ConcurrentQueue<EventLog>();
|
|
List<string> logs = new List<string>();
|
|
List<int> event_ids = new List<int>();
|
|
CollectorStatus status;
|
|
int verbose = 0;
|
|
|
|
|
|
EventCollector(string[] args)
|
|
{
|
|
status = CollectorStatus.starting;
|
|
|
|
var p = new OptionSet()
|
|
.Add("v", v => ++verbose)
|
|
.Add("log=", l => logs.Add(l))
|
|
.Add("id=", id =>
|
|
{
|
|
string[] elements = id.Split(',');
|
|
foreach (var i in elements)
|
|
{
|
|
int x = -1;
|
|
int.TryParse(i, out x);
|
|
if (x > 0) event_ids.Add(x);
|
|
}
|
|
});
|
|
p.Parse(args);
|
|
}
|
|
|
|
|
|
void Start() {
|
|
status = CollectorStatus.running;
|
|
|
|
Task.Run(() => {
|
|
while (RunCollect)
|
|
{
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
void Stop() {
|
|
RunCollect = false;
|
|
}
|
|
|
|
|
|
void Pause() {
|
|
status = CollectorStatus.paused;
|
|
}
|
|
}
|
|
|
|
enum CollectorStatus
|
|
{
|
|
running,
|
|
paused,
|
|
starting,
|
|
stopping,
|
|
}
|
|
}
|