venus najad

venus najad

  • 1.3k
  • 414
  • 28.5k

how to make outer while loop runs slower than the inner one

Mar 3 2019 10:10 AM
hello... i need help with making my outer whileloop runs slower than the inner while loop...
to make them that both runs at the same moment, i have used continue method...
but when i compile, the inner loop runs with the same rate as outer one...i have used thread.sleep(1000) for outer loop and thread.sleep(1) for inner loop... when i compile, the innner loop goes each second instead of each milisecond.. my continue make the inner loop dependent on outer loop... appreciate any help...
the codes are:
  1. while (t == true)  
  2. {  
  3. try {  
  4. cd.TimeTick();//tick time  
  5. lblTime.Text = cd.GetTime();//put time  
  6. Thread.Sleep(1000); //delay with one second  
  7. Application.DoEvents();  
  8. while (tLu == true)  
  9. {  
  10. try {  
  11. cdLu.TimeTick();//tick time  
  12. lblLunch.Text = cdLu.GetTime();//put time  
  13. Thread.Sleep(1); //delay with one milisecond  
  14. Application.DoEvents();  
  15. throw new Exception();  
  16. }  
  17. catch (Exception)  
  18. {  
  19. throw new Continue();  
  20. }  
  21. }  
  22. [Serializable]  
  23. internal class Continue : Exception  
  24. {  
  25. public Continue()  
  26. {  
  27. }  
  28. public Continue(string message) : base(message)  
  29. {  
  30. }  
  31. public Continue(string message, Exception innerException) : base(message, innerException)  
  32. {  
  33. }  
  34. protected Continue(SerializationInfo info, StreamingContext context) : base(info, context)  
  35. {  
  36. }  
  37. }  

Answers (8)