title: C++ async OutputDebugString
body: <p>With the new std::async in c++11, I thought I might go about trying to implement an async version of OutputDebugString to free me of some of the performance downs that result from my usual heavy printing of every little detail through the usual OutputDebugString function.</p>
  
  <p>So here is my original sync OutputDebugString implementation(which works):</p>
  
  <pre><code>static void OutputDebugStringN(const char *format, ...)
  {
      char outstring[256];
      memset(outstring, 0, sizeof(outstring));
  
      try
      {
          va_list args = {0};
          va_start(args, format); //args = (va_list) (&amp;format+1);
  
          vsprintf_s(outstring, format, args);
  
          va_end(args);
  
          OutputDebugString(outstring);
      }
      catch (...) //most likely reference val arg error (va_list doesn't support ref args)
      {
          OutputDebugString("[OutputDebugStringN] Something went wrong\n");
      }
  }
  </code></pre>
  
  <p>and the following my very naiive attempt at an async version(which doesn't work):</p>
  
  <pre><code>static void OutputDebugStringN(const char *format, ...)
  {
      auto future = std::async([]{
          char outstring[256];
          memset(outstring, 0, sizeof(outstring));
          try
          {
              va_list args = {0};
              va_start(args, format); //args = (va_list) (&amp;format+1);
  
              vsprintf_s(outstring, format, args);
  
              va_end(args);
  
              OutputDebugString(outstring);
          }
          catch (...) //most likely reference val arg error (va_list doesn't support ref args)
          {
              OutputDebugString("[OutputDebugStringN] Something went wrong\n");
          }
      }); 
  }
  </code></pre>
  
  <p>And since the above doesn't work I'm now at the point where I'm starting to think that async calling OutputDebugStringN might be better than trying to launch an async job inside the function itself as so (which works, but cumbersome):</p>
  
  <pre><code>auto dstring = std::async([]{ OutputDebugStringN("[NovelScript::ParseTokens] searched bookmark: \"%s\" does not exist\n", bookmark.c_str());} );
  </code></pre>
  
  <p>So here are two questions I'd like to ask:</p>
  
  <ol>
  <li>How should I be going about implementing an async version of OutputDebugString?</li>
  <li>Should I even be trying to implement an async version of OutputDebugString?</li>
  </ol>
  
  <p>Criticism on the above code and any other comments are also much welcome.</p>