0

以下のような ASP.NET MVC コントローラー メソッドがあります。

    public JsonResult GenerateNotifications()
    {
        Task.Factory.StartNew(() => MyService.GenerateNotifications());
        return Json(new { success = true }, JsonRequestBehavior.AllowGet);
    }

My Service メソッドは次のようになります。

    public async void GenerateNotifications()
    {
        NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(AppHelper.AzureNotificationHubConnectionString, "myhub");

        for (int i = 0; i < 10; i++)
        {
            var notification = new
            {
                aps = new
                {
                    alert = string.Format("Awesome Notification {0}", i),
                    sound = "default"
                }
            };

            string notificationJSON = JsonConvert.SerializeObject(notification);
            NotificationOutcome result = await hub.SendAppleNativeNotificationAsync(notificationJSON, "mytag");
        }
    }

私が抱えている問題は、受信するはずの 10 件の通知のうち、通常は 5 ~ 6 件しか受信しないことです。

async通話の処理方法に何か問題がありますか?

コントローラーとは別の方法で通知を生成する必要がありますか?

4

1 に答える 1