Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8714785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:41:00+00:00 2026-06-13T05:41:00+00:00

i am trying to avoid the wait time, taken by sending an email before

  • 0

i am trying to avoid the wait time, taken by sending an email
before exiting page.

the page/application is doing a sequence of actions before exiting as follows :

  1. database interaction
  2. Send Email (updates a manager about that transaction)
  3. Exit page / application .

code behind function :

    ExecEntryOnTbl(SQL);// <-- update / insert to database 
    sendMailNote(action);// <-- send mail with notification of update 

    exitTC(action, custid);<-- exit page.

    done via javascript :
    window.location.href = "someOtherPage.aspx"
    from code behind via 
    RegisterClientScriptBlock(...)

i would like to solve the issue :

how can i avoid waiting for the sendMailNote() to complete
before following exitTC() could be executed. is that possible ?

  • update email class/method

    public static class mail
    {
        public static string aReciver, bSubject, cBody;
        public static void sendMailNoteExc()
        {
    
            string SmtpServer = "smtp.gmail.com";
            int port = 111;
            string sender = "aaa@bbb.com";
            string ReCiver = aReciver;
            string Subject = bSubject;
            string Body = cBody;
            string account = "acc@domain.com";
            string Pass = "a123456";
            Send(SmtpServer, port, account, Pass, sender, ReCiver, Subject, Body);
    
        }
        public static void Send(string smtpServer,int Port,string Account, string PassWord, string From, string To, string Subject, string Body)
        {
    
            MailMessage mail = new MailMessage();
            SmtpClient SmtpServer = new SmtpClient(smtpServer);
    
            mail.From = new MailAddress(From);
            mail.To.Add(To);
            mail.Subject = Subject;
            mail.Body = Body;
    
    
            SmtpServer.Port = Port;
            SmtpServer.Credentials = new System.Net.NetworkCredential(Account, PassWord);
            SmtpServer.EnableSsl = true;
    
            SmtpServer.Send(mail);
    
    
        }
    }
    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:41:01+00:00Added an answer on June 13, 2026 at 5:41 am

    As long as you are using C# 4.0 you can take advantage of Task Parallel Library and run sendMailNote(action) in the background thread like this:

    Task.Factory.StartNew(() => sendMailNote(action));
    

    Just make sure you add a code to handle any exceptions occured during sending an email. However the better solution would be to remove this logic from the user interface code altogether and execute it in a background task like windows service or cloud worker role.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm probably over-thinking this/wasting time trying to avoid a bit of conditional code -
Trying to avoid re-inventing the wheel here. I have a Google Web Toolkit page
Trying to avoid the SomethingManager trap here... Let's say I'm going to write a
Also trying to avoid any use of plugins, (apart from jQuery of course, whether
I am trying to avoid C6011 warning because an abort function is calling exit().
I'm trying to avoid the use of magic strings as much as I can,
I'm trying to avoid the memory leak in PHP. When I create a object
I'm trying to avoid using Interface Builder as much as possible. At the moment
I'm trying to avoid jQuery and would like to use a native solution. How
I am just trying to avoid context switching as it introduces a lot of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.