You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
976 B

2 years ago
  1. using Microsoft.AspNet.SignalR;
  2. using System;
  3. using System.Threading.Tasks;
  4. using WebApp.Hubs;
  5. namespace WebApp
  6. {
  7. public class BackgroundThread
  8. {
  9. public static bool Enabled { get; set; }
  10. public static async Task SendOnHubAsync()
  11. {
  12. var context = GlobalHost.ConnectionManager.GetHubContext<MsgHub>();
  13. while (Enabled)
  14. {
  15. //var db = DBUnit.Instance;
  16. //OVW_SYS_Announcement oEip = new OVW_SYS_Announcement();
  17. //var saAnn = db.Queryable<OVW_SYS_Announcement>().Where(it => it.EndDateTime == DateTime.Now).ToList();
  18. //if (msg.ConnectionIds.Count > 0)
  19. //{
  20. // await context.Clients.Clients(msg.ConnectionIds).message(msg); // 特定的客户端,只對當前在綫人員推送
  21. //}
  22. await Task.Delay(TimeSpan.FromMinutes(1));//目前以一分鐘為准
  23. }
  24. }
  25. }
  26. }