Click here to Skip to main content
       

ASP.NET

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: Create a basic captcha in C#.net PinmemberMember 870181328 Feb '13 - 6:29 
AnswerRe: Create a basic captcha in C#.net PinmemberAshishChaudha28 Feb '13 - 17:11 
Questionthreaded function to send email, file io crashes Pinmemberjkirkerx27 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 PinmemberRichard Deeming27 Feb '13 - 9:30 
GeneralRe: threaded function to send email, file io crashes Pinmemberjkirkerx27 Feb '13 - 11:28 
AnswerRe: file io crashes PinmemberDavid Mujica27 Feb '13 - 10:40 
QuestionTextArea value in C# Pinmembervanikanc27 Feb '13 - 8:03 
AnswerRe: TextArea value in C# PinmvpSandeep Mewara27 Feb '13 - 18:12 
GeneralRe: TextArea value in C# PinmemberAli Al Omairi(Abu AlHassan)27 Feb '13 - 20:09 
GeneralRe: TextArea value in C# PinmvpSandeep Mewara27 Feb '13 - 21:02 

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

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


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid