Files
quantconnect--lean/UserInterface/Program.cs
Andrew Hart 7b533001d8 LeanWinForm.cs now implements IMessageHandler
The WinForm application now implements the interface that allows the DesktopClient to pass messages to it. This replaces the delegate methods that were being used before.

The Main method in the Views project now starts the NetMQ pull socket (server) in another thread.  This is so the server does no block the rest of the WinForms application.  The server is then shut down once the application is finished running.
2016-08-31 12:35:17 -04:00

36 lines
926 B
C#

using System;
using System.Threading;
using System.Windows.Forms;
using QuantConnect.Views.WinForms;
namespace QuantConnect.Views
{
public class Program
{
[STAThread]
static void Main(string[] args)
{
if (args.Length != 1)
{
throw new Exception(
"Error: You must specify the port on which the application will open a TCP socket.");
}
var port = args[0];
var form = new LeanWinForm();
var desktopClient = new DesktopClient();
var thread = new Thread(() => desktopClient.Run(port, form));
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
Application.Run(form);
// The above code is blocking.
// Once it finishes, close the NetMQ client
desktopClient.StopServer();
}
}
}