title: Passing a struct instance by reference to ParameterizedThreadStart
body: <p>I want to start a thread and as a parameter pass an instance of a struct by reference. The <code>ref</code> keyword worked fine before using threads but I can't seem to use <code>ref</code> now.</p>
  
  <p>This is how my code currently is:</p>
  
  <pre><code>Thread melodyThread = new Thread(new ParameterizedThreadStart(PlayMelody));
  melodyThread.Start(melody1);
  
  private void PlayMelody(object parameter)
  {
      Melody melody = (Melody)parameter;
      .
      .
      .
  }
  </code></pre>
  
  <p>I want to pass an instance of struct <code>Melody</code> (<code>melody1</code>) by reference. Thanks.</p>