Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to implement an asynchronous code?

How to implement an asynchronous code?

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdatabasexml
2 Posts 2 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TRAORE cheickna
    wrote on last edited by
    #1

    Hello, Into my asp.net application every day i download an xml file and store the values in my database. After did this, i display this xml file using an aspx page. After displaying, an e-mail is sent to 2000 users who are subscribe to this info. My problem is that i want to dipslay first the page to confirm there is no problem, then send the e-mail but because i use Response.Redirect function my code for sending e-mail is never run. If i send first the e-mail, i must wait for the end (5 minutes) before displaying xml value into my page. Therefore i would to display my page and execute at the same time the function to send e-mail or sending the e-mail in asynchronous mode. The part of my code with this problem is the following :

    'Storing data in my database
    iRes = mydb.DBRecordPublication(strFilename, sDate, snumero, sDoc)
    If iRes >= 0 Then
    'Displaying data on screen
    Dim NomMagazine As String = strFilename
    Response.Redirect("ShowNews.aspx?News=" & NomMagazine & "&DateNews=" & sDate & "&ConnecString=" & mydb.GetConnectionString())
    'Sending e-mail : Never run after Response.Redirect
    Dim strRes As String = myMail.SendSommaire(Me.Context)
    end if

    thanks in advance for any help

    N 1 Reply Last reply
    0
    • T TRAORE cheickna

      Hello, Into my asp.net application every day i download an xml file and store the values in my database. After did this, i display this xml file using an aspx page. After displaying, an e-mail is sent to 2000 users who are subscribe to this info. My problem is that i want to dipslay first the page to confirm there is no problem, then send the e-mail but because i use Response.Redirect function my code for sending e-mail is never run. If i send first the e-mail, i must wait for the end (5 minutes) before displaying xml value into my page. Therefore i would to display my page and execute at the same time the function to send e-mail or sending the e-mail in asynchronous mode. The part of my code with this problem is the following :

      'Storing data in my database
      iRes = mydb.DBRecordPublication(strFilename, sDate, snumero, sDoc)
      If iRes >= 0 Then
      'Displaying data on screen
      Dim NomMagazine As String = strFilename
      Response.Redirect("ShowNews.aspx?News=" & NomMagazine & "&DateNews=" & sDate & "&ConnecString=" & mydb.GetConnectionString())
      'Sending e-mail : Never run after Response.Redirect
      Dim strRes As String = myMail.SendSommaire(Me.Context)
      end if

      thanks in advance for any help

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Although you can implement an aysnc page you may be better using Ajax. Display the page with a button to send the emails. The button will call an Ajax function that will send the emails. A side benefit is you can get updates on the number of emails sent, if you code it that way.


      No comment

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups