首页 > 技术文章 > 异步发送

vinsonLu 2018-05-28 16:27 原文

        /// <summary>
        /// 发送  改成异步发送了
        /// </summary>
        /// <param name="userList"></param>
        /// <param name="message"></param>
        /// <param name="title"></param>
        /// <param name="notifyenum"></param>
        private static void Notify(NotifyContext noticontext, List<IssuedType> notifyenum)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    notifyenum.ForEach(p =>
                    {
                        BaseNotifier noti = null;
                        #region 实例
                        //邮件
                        if (p == IssuedType.Mail)
                        {
                            noti = new MailNotifier();
                        }
                        //App
                        if (p == IssuedType.App)
                        {
                            noti = new AppNotifier();
                        }
                        //短信
                        if (p == IssuedType.SMS)
                        {
                            noti = new SMSNotifier();
                        }
                        #endregion

                        #region 赋值发送
                        if (noti != null)
                        {
                            noti.Context = noticontext;
                            noti.Notify();


                        }
                        #endregion
                    });
                }
                catch (Exception ex) { Dao.Get().ExecuteNonQuery("insert into vinson_msg(msg) values('" + ex.Message + "')"); }
            });
        }

 

推荐阅读