title: Visual Studio Thread Statement gives Error?
body: <p>I decompiled a .NET Application to write my own Injection Software. A Thread Error don't want to get removed. I tried everything but it keeps telling me that something is wrong...</p>
  
  <p><a href="https://i.stack.imgur.com/xbW18.png" rel="nofollow noreferrer">Code (Screenshot)</a></p>
  
  <pre><code>{
      using System;
      using System.IO;
      using System.IO.Pipes;
      using System.Runtime.InteropServices;
      using System.Text;
      using System.Threading;
      using System.Windows.Forms;
  
      internal class NamedPipes
      {
          public static string luapipename = "IDUNNOPIPE123";
  
          public static void LuaPipe(string script)
          {
              if (NamedPipeExist(luapipename))
              {
                  new Thread (delegate {
                      try
                      {
                          using (NamedPipeClientStream stream = new NamedPipeClientStream(".", luapipename, PipeDirection.Out))
                          {
                              stream.Connect();
                              using (StreamWriter writer = new StreamWriter(stream, Encoding.Default, 0xf423f))
                              {
                                  writer.Write(script);
                                  writer.Dispose();
                              }
                              stream.Dispose();
                          }
                      }
                      catch (IOException)
                      {
                          MessageBox.Show("Error occured connecting to the pipe.", "Connection Failed!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                      }
                      catch (Exception exception1)
                      {
                          MessageBox.Show(exception1.Message.ToString());
                      }
                  }).Start();
              }
              else
              {
                  MessageBox.Show("Please Inject " + Functions.exploitdllname + " before Using this!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
              }
          }
  
          public static bool NamedPipeExist(string pipeName)
          {
              bool flag;
              try
              {
                  int timeout = 0;
                  if (!WaitNamedPipe(Path.GetFullPath($"\\\\.\\pipe\\{pipeName}"), timeout))
                  {
                      bool flag4;
                      int num2 = Marshal.GetLastWin32Error();
                      if (num2 != 0)
                      {
                          if (num2 != 2)
                          {
                              goto TR_0005;
                          }
                          else
                          {
                              flag4 = false;
                          }
                      }
                      else
                      {
                          flag4 = false;
                      }
                      return flag4;
                  }
              TR_0005:
                  flag = true;
              }
              catch (Exception)
              {
                  flag = false;
              }
              return flag;
          }
  
          [return: MarshalAs(UnmanagedType.Bool)]
          [DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
          private static extern bool WaitNamedPipe(string name, int timeout);
      }
  }
  </code></pre>