Can somebody explain why when running this code and then stopping the EventManager, "StopTest::Stopping" and "StopTest::Done" never print? thanks
using System; using System.Threading;
using SmartQuant;
namespace OpenQuant { public class StopTest { public bool Stopped = false; public Framework Framework; public void Stop(object sender, EventArgs e) { Console.WriteLine("StopTest::Stopping"); Framework.EventManager.Dispatcher.EventManagerStopped -= Stop; Stopped = true; } public void Run() { Framework = Framework.Current; Framework.EventManager.Dispatcher.EventManagerStopped += Stop; while (!Stopped) { Console.WriteLine(DateTime.Now); Thread.Sleep(1000); } Console.WriteLine("StopTest::Done"); } public static void Main(string[] args) { StopTest stopTest = new StopTest(); stopTest.Run(); } } }
|