/// <summary> /// Get the computed response from the thread we spawned /// </summary> /// <param name="fb">The object that handled the thread and did the computing</param> /// <param name="txtMessages">A text box to write commentary into. Can't be null.</param> /// <returns></returns> private static Boolean GetResponse(FantasticBeast fb, TextBox txtMessages) { Boolean result = true; // Hope for the best // The thread should have responded to our request so we can retrieve it. txtMessages.AppendText(Environment.NewLine + "Response from " + fb.GetType() + ": " + fb.response); if (fb.response.Trim() == "19541") { txtMessages.AppendText(": solution is correct"); } else { txtMessages.AppendText(": solution IS NOT correct"); result = false; } return(result); }
/// <summary> /// Spawn the thread from the Fantastic Beast object /// </summary> /// <param name="fb">The object that will handle the thread.</param> /// <param name="txtMessages">A text box to write commentary into. Can't be null.</param> private static void Spawn(FantasticBeast fb, TextBox txtMessages) { txtMessages.AppendText(Environment.NewLine + "Spawning " + fb.GetType()); fb.Start(); // This will invoke RunThread in the derived class }
/// <summary> /// Get the message from the thread we spawned /// </summary> /// <param name="fb">The object that handled the thread and did the computing</param> /// <param name="txtMessages">A text box to write commentary into. Can't be null.</param> private static void GetMsg(FantasticBeast fb, TextBox txtMessages) { // The thread should have written a message so we can retrieve it. txtMessages.AppendText(Environment.NewLine + fb.msg); }