title: C# program (process) will not unload
body: <p>I have a C# program that uses a class from another assembly, and this class calls an unmanaged DLL to do some processing.  Here is a snippet:</p>
  
  <pre><code>public class Util
  {
      const string dllName = "unmanaged.dll";
      [DllImport(dllName, EntryPoint = "ExFunc")]
      unsafe static extern bool ExFunc(StringBuilder path, uint field);
  
      public bool Func(string path, uint field)
      {
          return ExFunc(new StringBuilder(path), field);
      }
  
      ...
  }
  
  Util util = new Util();
  bool val = util.Func("/path/to/something/", 1);
  </code></pre>
  
  <p>The problem I'm having is that if I call "Func" my main C# program will not unload.  When I call Close() inside my main form the process will still be there if I look in Task Manager.  If I remove the call to "Func" the program unloads fine.  I have done some testing and the programs Main function definitely returns so I'm not sure what's going on here.  </p>