From e14db2ad9a18ea79679192d657a720da70f5313c Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sat, 6 Jun 2020 13:20:37 -0700 Subject: [PATCH] Hilos en envio de correo, --- App_Code/ClsSisNotificaciones.vb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/App_Code/ClsSisNotificaciones.vb b/App_Code/ClsSisNotificaciones.vb index 79b05c132..b63c12e88 100644 --- a/App_Code/ClsSisNotificaciones.vb +++ b/App_Code/ClsSisNotificaciones.vb @@ -209,24 +209,25 @@ Public Class ClsSisNotificaciones #Region "C O R R E O" Private Sub EnviarCorreos(DTNotificacionesCorreo As DataTable) - For Each notificacion As DataRow In DTNotificacionesCorreo.Rows - MandaMail(notificacion("CveNotificacionBitacora").ToString.ToEntero, notificacion("Encabezado").ToString, notificacion("Cuerpo").ToString, notificacion("Correo").ToString, "") + For Each notificacion As DataRow In DTNotificacionesCorreo.Rows + Dim Hilo As New System.Threading.Thread(Sub() MandaMail(notificacion("CveNotificacionBitacora").ToString.ToEntero, notificacion("Encabezado").ToString, notificacion("Cuerpo").ToString, notificacion("Correo").ToString, "")) + Hilo.Start() Next End Sub Private Sub MandaMail(CveNotificacionBitacora As Integer, Asunto As String, Cuerpo As String, Mail As String, MailCC As String) Dim ObjMail As New ClsSisMail() - + Dim ObjNotificacion As New ClsSisNotificaciones Try Dim ResultadoMail As Integer = 0 Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) If ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Mail, Asunto, Cuerpo, MailCC, LSRutasMail) Then - UpdateNotificacionesBitacoraNotifico(CveNotificacionBitacora, 1) + ObjNotificacion.UpdateNotificacionesBitacoraNotifico(CveNotificacionBitacora, 1) End If - Catch ex As Exception OnError("Ocurrió error al mandar el Mail", ex) End Try + ObjNotificacion.Dispose() End Sub #End Region @@ -1328,10 +1329,6 @@ Public Class ClsSisNotificaciones Next End If - If DTNotificacionesCorreo IsNot Nothing AndAlso DTNotificacionesCorreo.Rows.Count > 0 Then - EnviarCorreos(DTNotificacionesCorreo) - End If - If DTNotificacionesApp IsNot Nothing AndAlso DTNotificacionesApp.Rows.Count > 0 Then Dim DtTokens As DataTable = Nothing @@ -1389,6 +1386,10 @@ Public Class ClsSisNotificaciones DtTokens.Dispose() End If End If + End If + + If DTNotificacionesCorreo IsNot Nothing AndAlso DTNotificacionesCorreo.Rows.Count > 0 Then + EnviarCorreos(DTNotificacionesCorreo) End If If Not DTNotificacionesApp Is Nothing Then DTNotificacionesApp.Dispose()