Ejemplo n.º 1
0
    public void ThreadSafeLogThreadSafetyTest() {
      int count = 10000;
      ThreadSafeLog log = new ThreadSafeLog();

      Parallel.For(0, count, (i) => {
        log.LogMessage("Message " + i); // write something
        log.Messages.Count(); // iterate over all messages
      });

      Assert.AreEqual(count, log.Messages.Count());
    }
Ejemplo n.º 2
0
    public Core() {
      var log = new ThreadSafeLog(SlaveCore.Properties.Settings.Default.MaxLogCount);
      this.pluginManager = new PluginManager(WcfService.Instance, log);
      this.taskManager = new TaskManager(pluginManager, log);
      log.MessageAdded += new EventHandler<EventArgs<string>>(log_MessageAdded);

      RegisterTaskManagerEvents();

      this.configManager = new ConfigManager(taskManager);
      ConfigManager.Instance = this.configManager;
    }
Ejemplo n.º 3
0
 private ThreadSafeLog(ThreadSafeLog original, Cloner cloner)
     : base(original, cloner)
 {
     this.messages        = new ConcurrentQueue <string>(original.messages);
     this.maxMessageCount = original.maxMessageCount;
 }
Ejemplo n.º 4
0
 private ThreadSafeLog(ThreadSafeLog original, Cloner cloner)
   : base(original, cloner) {
   this.messages = new ConcurrentQueue<string>(original.messages);
   this.maxMessageCount = original.maxMessageCount;
 }