异步发送

        /// <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 + "')"); }
            });
        }
原文地址:https://www.cnblogs.com/vinsonLu/p/9100779.html