title: Threading and SOLID principle
body: <p>I have a the following code setup</p>
  
  <pre><code>public interface ILogger
  {
    void WriteData(string Data);
  }
  
  public class Logger : ILogger
  {
    public void WriteData(string Data)
    {
       //Write to disk   
    }
  }
  
  public interface ILogic
  {
    void ProcessData(string Data);
  }
  
  public class Logic : ILogic
  {
    private ILogger Logger;
  
    public Logic(ILogger Logger)
    {
      this.Logger = Logger;
    }
  
    public void ProcessData(string Data)
    {
       //Do stuff
       Logger.WriteData("Data to write");
    }
  }
  
  public class MainEntryPointClass
  {
       private BlockingCollection&lt;string&gt; DataInCollection;
       private Task DataInTask;
       private CancellationTokenSource CancellationTokenSource;
  
       public Start()
       {
          InitializeDataIn();
       }
  
          private void InitializeDataIn()
          {
              CancellationTokenSource = new CancellationTokenSource();
              DataInCollection = new BlockingCollection&lt;DataInContents&gt;();
              DataInTask = Task.Factory.StartNew(() =&gt; ProcessDataIn(CancellationTokenSource.Token));
          }
  
        private void ProcessDataIn(CancellationToken CancelToken)
          {
              while (!CancelToken.IsCancellationRequested)
              {
                  foreach (var item in DataInCollection.GetConsumingEnumerable())
                  {
                      Logic.ProcessData(item);
                  }
              }
  
          }
  }
  </code></pre>
  
  <p>So I create a new Task in my main class and then data is added to the DataInCollection to queue up data as it comes in, we're talking every 30ms or so. This gets processed successfully.  </p>
  
  <p>I now want to write data to file on a separate thread just so if there is a disk problem the main logic checking isn't impacted. If there is a disk problem then the logic can continue. I'm just not sure where I do the file writing on the separate thread? Is it in the Main class, the Logic class or the Logger class?</p>