示例#1
0
 private static void TimerOnTick(object sender, EventArgs eventArgs)
 {
     double price;
     // ReSharper disable PossibleNullReferenceException
     if(_browser != null && double.TryParse(_browser.Document.GetElementById("last_last").InnerText, NumberStyles.Float, _numberFormat, out price))
     // ReSharper restore PossibleNullReferenceException
     {
         using(var client = new OrderServiceClient())
         {
             SetPriceDataContractResponse response = null;
             try
             {
                 response = client.SetPrice(new SetPriceDataContractRequest
                 {
                     ProcessId = Process.GetCurrentProcess().Id,
                     SymbolId = _symbolId,
                     Price = price
                 });
             } catch(Exception ex)
             {
                 _logger.Error(ex);
                 //
                 Application.Exit();
                 return;
             }
             if(!string.IsNullOrEmpty(response.Error))
             {
                 _logger.Error("Error got from server: {0}", response.Error);
             }
             //
             if(response.StopSignal)
             {
                 _logger.Info("Stop signal received. Symbol: {0}", _symbolId);
                 //
                 Application.Exit();
             }
         }
     }
 }