SmartQuant Discussion
http://www.smartquant.com/forums/

What does the event EventManagerStopped do?
http://www.smartquant.com/forums/viewtopic.php?f=60&t=14899
Page 1 of 1

Author:  abasqd [ Thu Apr 04, 2019 5:13 am ]
Post subject:  What does the event EventManagerStopped do?

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();
}
}
}

Author:  skuvv [ Mon Jul 08, 2019 12:11 pm ]
Post subject:  Re: What does the event EventManagerStopped do?

Hello, abasqd.
When you call Console.WriteLine(...), the message will be placed in queue.
In this moment EventManager can be stopped and message still in queue and will not be read/printed.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/