static async Task Main(string[] args) { // We first need to authenticate and obtain a new access token. Then we need to get User Principals which // contains additional information we need for accessing resources such as streaming data Authentication auth = new Authentication(); await auth.RefreshAccessToken(); await auth.GetUserPrincipals(); // Create an instance of the StreamingProvider which will be used for processing the streaming data Streamer streamer = new Streamer(auth.StreamingCredentials); // Register to recieve data events. Any data events we receive will be sent to the dataReceived() function. streamer.DataReceived += dataReceived; // Register to receive debug logging data. This is only necessary when you are making changes to the application // and want to make sure there are no errors. Comment out the following line to hide the debug log information. streamer.DebugDataReceived += DebugLogDataReceived; // register to receive confirmation from requests being sent. streamer.RequestResponseReceived += RequestResponseReceived; // Enable data capture recording for 60 seconds //streamer.StartCapturingData("datacapture.txt", 60); // Example code to play back previously captured data at 1-second intervals // streamer.PlaybackCapturedData("datacapture.txt", 3000); // await Task.Delay(90000); // return; // Create a cancellation token which will be used to cancel the asynchrnous websocket later var cts = new CancellationTokenSource(); Console.CancelKeyPress += (sender, e) => { Console.WriteLine("Closing streaming connection and exiting..."); cts.Cancel(); }; Console.WriteLine("Press ESC to Exit"); var tasks = new List <Task> { streamer.StartDataStreaming(auth.UserPrincipal.streamerInfo.streamerSocketUrl, cts.Token) }; Thread.Sleep(2000); // Sleep for 2 seconds before we issue any commands // TIMESALE_EQUITY var symbols = new string[] { "AAPL,MSFT" }; streamer.SendRequest(ServiceRequestFactory.CreateTimesaleEquityRequest(auth.StreamingCredentials, symbols)); // TIMESALE_FUTURES symbols = new string[] { "/ES" }; streamer.SendRequest(ServiceRequestFactory.CreateTimesaleFuturesRequest(auth.StreamingCredentials, symbols)); await Task.WhenAll(tasks); Console.WriteLine("All done, exiting application!"); }