예제 #1
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
            DateTime endTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 30, 00);

            Task.Run(() =>
            {
                while (true)
                {
                    Thread.Sleep(1000);
                    try
                    {
                        if (MonitorBp.CalChangeBp(Config.Bonds))
                        {
                            var ToSendJson = MonitorBp.GetJsonString(Config.BpChangeDict);
                            _hubContext.Clients.All.SendAsync("ReceiveBp", ToSendJson);
                        }
                        if (DateTime.Now > endTime)
                        {
                            System.Environment.Exit(0);
                        }
                    }
                    catch (Exception ex) {
                        Console.WriteLine(ex.ToString());
                    }
                }
            });
        }
예제 #2
0
 public override async Task OnConnectedAsync()
 {
     //string ToSendJson = JsonConvert.SerializeObject(Config.BpChangeDict, Formatting.Indented);
     var ToSendJson = MonitorBp.GetJsonString(Config.BpChangeDict);
     await Clients.Caller.SendAsync("ReceiveBp", ToSendJson);
 }