fork download
  1. using System;
  2. using System.Threading;
  3.  
  4. public class Test
  5. {
  6. public class Media
  7. {
  8. private Thread thread;
  9.  
  10. public Media()
  11. {
  12. thread = new Thread(new ThreadStart(Play));
  13. }
  14.  
  15. private void Play()
  16. {
  17. string[] files = {"requiem", "the magic flute", "Le nozze di Figaro"};
  18.  
  19. for (int i=0; i < files.Length; i++)
  20. {
  21. Console.WriteLine("playing " + files[i]);
  22. Thread.Sleep(3000);
  23. }
  24. }
  25.  
  26. public void PlaySound()
  27. {
  28. thread.Start();
  29. }
  30.  
  31. public void StopSound()
  32. {
  33. // don't actually abort
  34. // use flags etc
  35. thread.Abort();
  36. }
  37. }
  38.  
  39. public static void Main()
  40. {
  41. Media m = new Media();
  42.  
  43. m.PlaySound();
  44. }
  45. }
Success #stdin #stdout 0.02s 34888KB
stdin
Standard input is empty
stdout
playing requiem
playing the magic flute
playing Le nozze di Figaro