コード例 #1
0
        private static int Main(string[] args)
        {
            LoggingService loggingService = new LoggingService();
            Parallel.For(0, 100, (i) =>
            {
                new TaskFactory().StartNew(async() =>
                {
                    for (int j = 0;;j++)
                    {
                        LogEntry l = new LogEntry
                        {
                            Message = "message " + ++j,
                            EventTime = DateTime.Now,
                            LogSource = "source " + i
                        };
                        await loggingService.AddLog(l);
                        await Task.Delay(new Random().Next(10, 500));
                    }
                });
            });

            Console.WriteLine("Finished!");
            Console.ReadKey();
            return 0;
        }
コード例 #2
0
ファイル: DbLogChannel.cs プロジェクト: ntsmwk/LoggingAgent
 public void Log(LogEntry logEntry)
 {
     logEntries.Enqueue(logEntry);
 }
コード例 #3
0
ファイル: LoggingService.cs プロジェクト: ntsmwk/LoggingAgent
 public Task AddLog(LogEntry entry)
 {
     return new TaskFactory().StartNew(() =>  dbLogChannel.Log(entry));
 }