title: Service freezes when calling XDocument.Root.Add(XElement)
body: <p>I am working on a service that runs periodic scans on a certain folder to gather information about some of the files that are in it and its subfolders.</p>
  
  <p>I have tested the code in a console application and it runs through as expected, however when it runs from my service, the execution seems to get stuck at the part where it calls scanLog.Root.Add(temp);</p>
  
  <p>I can see the event entry that says "Starting to add node", however it never gets to "Finished adding node" any thoughts on why this doesn't work in my service, but works fine in a console application?</p>
  
  <pre><code>private void ScanForChildCopies(string dir)
      {
          foreach(var dirs in Directory.GetDirectories(dir))
          {
              ScanForChildCopies(dirs);
          }
  
          foreach(var files in Directory.GetFiles(dir, "*.ac"))
          {
              FileInfo fInfo = new FileInfo(files);
              serviceLogging.WriteEntry("Found File: " + files);
              if (fInfo.Exists)
              {
                  if ((DateTime.Now - fInfo.LastWriteTime).Days &gt; 0)
                  {
                      serviceLogging.WriteEntry("Building node");
                      XElement temp = new XElement("childfile", new XElement("name", fInfo.Name), new XElement("lastmodified", fInfo.LastWriteTime.ToShortDateString()),
                          new XElement("age", (DateTime.Now - fInfo.LastWriteTime).Days.ToString()));
                      serviceLogging.WriteEntry("Starting to add node");
                      scanLog.Root.Add(temp);
                      serviceLogging.WriteEntry("finished Adding node to scanlog");                 
                  }                    
              }
          }
  
  
  
      }
  </code></pre>