Пример #1
0
        public static void CreateAsyncTask(MailTask mailTask)
        {
            lock (_lock)
            {
                var status = new MassSendMailStatus();
                status.TaskId = mailTask.TaskId;
                if (!_threadPools.ContainsKey(mailTask.TaskId))
                {
                    MassSendThreadPool threadPool = new MassSendThreadPool();
                    _threadPools.Add(mailTask.TaskId, threadPool);

                    Task.Run(() =>
                    {
                        threadPool.Start(mailTask);
                    });
                }
            }
        }
Пример #2
0
        public static MassSendMailStatus QueryStatus(string taskId)
        {
            MassSendMailStatus status = null;

            lock (_lock)
            {
                if (_threadPools.ContainsKey(taskId))
                {
                    var threadPool = _threadPools[taskId];
                    status = threadPool.Status();
                    if (status.Completed)
                    {
                        _threadPools.Remove(taskId);
                    }
                }
            }

            return(status);
        }