Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sending Email Asynchronously
Message
De
18/01/2013 11:59:29
 
 
À
18/01/2013 09:40:05
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01563134
Message ID:
01563279
Vues:
53
>Think my last post was correct. Maybe remove the using when creating the SmtpClient and put 'client.Dispose()' in the delegate callback. i.e in outline:
SmtpClient client = new SmtpClient();
>                    {
>                        client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
>                            try
>                            {
>                                 client.SendCompleted += delegate
>                                {
>                                  client.Dispose();
>                                    lock (numRemainingLock)
>                                    {
>                                        if (--numRemaining == 0)
>                                        {
>                                            waitHandle.Set();
>                                        }
>                                    }
>                                };
>                                client.SendAsync(msg, userState);                 // Send our email.   
>                            }
>                            catch (Exception)
>                            {
>                                msg.Dispose();
>                                // throw;
>                            }
>                        }
>                    }
Superb! Thanks once again Viv. What is interesting is that all the email is now being sent, but the code never hits the SendCompletedCallback.

Oh, it also does not seem to be running asynchronously as I don't get control back in the UI for quite a while.

One of these days I'll understand C# :(
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform