public static void UpdateBadgeNumber() { int count; using (MainDbContext ctx = new MainDbContext()) { count = ctx.GetUnreadMessageCount(); } SetBadgeNumber(count); }