Click here to Skip to main content
15,882,113 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Create a basic captcha in C#.net Pin
Sandeep Mewara28-Feb-13 5:29
mveSandeep Mewara28-Feb-13 5:29 
GeneralRe: Create a basic captcha in C#.net Pin
Member 870181328-Feb-13 6:02
Member 870181328-Feb-13 6:02 
GeneralRe: Create a basic captcha in C#.net Pin
Sandeep Mewara28-Feb-13 6:23
mveSandeep Mewara28-Feb-13 6:23 
GeneralRe: Create a basic captcha in C#.net Pin
Member 870181328-Feb-13 6:28
Member 870181328-Feb-13 6:28 
GeneralRe: Create a basic captcha in C#.net Pin
Member 870181328-Feb-13 6:24
Member 870181328-Feb-13 6:24 
GeneralRe: Create a basic captcha in C#.net Pin
Member 870181328-Feb-13 6:29
Member 870181328-Feb-13 6:29 
AnswerRe: Create a basic captcha in C#.net Pin
AshishChaudha28-Feb-13 17:11
AshishChaudha28-Feb-13 17:11 
Questionthreaded function to send email, file io crashes Pin
jkirkerx27-Feb-13 8:29
professionaljkirkerx27-Feb-13 8:29 
I wrote a function that sends an email on a separate thread in 4.0

I've had trouble with the thread, in getting each one to queue up, but I think I fixed that part.

In the thread, I have a function that reads a HTML file with data fields, and populates the fields with data, I call it my flexible HTML templates. After populating the data, I package the new HTML as the Netmail.Body, to transmit in the message.

So on this message, I send a copy to 3 people, and every once in a while on the 2nd and 3rd copy of the message, it bombs reading the file, because the file is locked or something.

Looking for any ideas on how to fix it.

I'm not sure if I should focus on the file i/o, or on the thread itself, or scrap the idea completely.

Just a general idea of what I'm doing

try
     'Read the Html Template from App_Data, and format the template fields
      htmlStream = New FileStream(m_PhysicalPath, FileMode.Open, FileAccess.Read)
      Dim htmlLen As Long = htmlStream.Length
      Dim fileData As Byte() = New Byte(htmlLen) {}
      htmlStream.Read(fileData, 0, htmlLen)

      If Not (htmlStream Is Nothing) Then htmlStream.Close()

      Dim byteLine() As Byte = New Byte() {}
      Dim strArray() As String = New String() {}
      For bdx As Integer = 0 To fileData.Length - 1

          Dim byteVal As Byte = fileData(bdx)
          If Not (byteVal = &HD) Then

              Array.Resize(byteLine, byteLine.Length + 1)
              byteLine(byteLine.Length - 1) = byteVal

          Else
              Array.Resize(byteLine, byteLine.Length + 1)
              byteLine(byteLine.Length - 1) = byteVal

              Dim charLine() As Char = New Char() {}
              Array.Resize(charLine, byteLine.Length + 1)

              For cdx As Integer = 0 To byteLine.Length - 1
                  charLine(cdx) = AsciiByteToChar(byteLine(cdx))
              Next

              Dim value As String = New String(charLine)
              Array.Resize(strArray, strArray.Length + 1)
              strArray(strArray.Length - 1) = value

              Array.Resize(byteLine, 0)
              bdx += 1

          End If
      Next

  Catch ex As Exception

      m_html_Template = New StringBuilder
      m_html_Template.Append("load_HTML_Template_Checkout_Complete general error")
      dwExitCode = 1

  Finally

      If Not (htmlStream Is Nothing) Then
          htmlStream.Close()
          htmlStream.Dispose()
          htmlStream = Nothing
      End If

  End Try

SuggestionRe: threaded function to send email, file io crashes Pin
Richard Deeming27-Feb-13 9:30
mveRichard Deeming27-Feb-13 9:30 
GeneralRe: threaded function to send email, file io crashes Pin
jkirkerx27-Feb-13 11:28
professionaljkirkerx27-Feb-13 11:28 
AnswerRe: file io crashes Pin
David Mujica27-Feb-13 10:40
David Mujica27-Feb-13 10:40 
QuestionTextArea value in C# Pin
vanikanc27-Feb-13 8:03
vanikanc27-Feb-13 8:03 
AnswerRe: TextArea value in C# Pin
Sandeep Mewara27-Feb-13 18:12
mveSandeep Mewara27-Feb-13 18:12 
GeneralRe: TextArea value in C# Pin
Ali Al Omairi(Abu AlHassan)27-Feb-13 20:09
professionalAli Al Omairi(Abu AlHassan)27-Feb-13 20:09 
GeneralRe: TextArea value in C# Pin
Sandeep Mewara27-Feb-13 21:02
mveSandeep Mewara27-Feb-13 21:02 
GeneralRe: TextArea value in C# Pin
Ali Al Omairi(Abu AlHassan)27-Feb-13 22:03
professionalAli Al Omairi(Abu AlHassan)27-Feb-13 22:03 
GeneralRe: TextArea value in C# Pin
Sandeep Mewara27-Feb-13 23:16
mveSandeep Mewara27-Feb-13 23:16 
AnswerRe: TextArea value in C# Pin
Ali Al Omairi(Abu AlHassan)27-Feb-13 20:06
professionalAli Al Omairi(Abu AlHassan)27-Feb-13 20:06 
GeneralRe: TextArea value in C# Pin
vanikanc28-Feb-13 2:38
vanikanc28-Feb-13 2:38 
GeneralRe: TextArea value in C# Pin
Ali Al Omairi(Abu AlHassan)4-Mar-13 4:13
professionalAli Al Omairi(Abu AlHassan)4-Mar-13 4:13 
QuestionDataset Issue Pin
Abhismart5527-Feb-13 3:18
Abhismart5527-Feb-13 3:18 
AnswerRe: Dataset Issue Pin
Abhismart5527-Feb-13 7:15
Abhismart5527-Feb-13 7:15 
QuestionProblems with display image byte() on image tag Pin
keidash27-Feb-13 0:36
keidash27-Feb-13 0:36 
AnswerRe: Problems with display image byte() on image tag Pin
Ali Al Omairi(Abu AlHassan)4-Mar-13 3:26
professionalAli Al Omairi(Abu AlHassan)4-Mar-13 3:26 
Questionwhy team is not replyin gmy question Pin
prince_rumeel26-Feb-13 23:13
prince_rumeel26-Feb-13 23:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.