SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Oct 23, 2019 5:45 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Apr 04, 2019 5:13 am 
Offline

Joined: Thu Dec 06, 2018 1:57 am
Posts: 28
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();
}
}
}


Top
 Profile  
 
PostPosted: Mon Jul 08, 2019 12:11 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 536
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group