Click here to Skip to main content
   

ASP.NET

 
GeneralRe: Create a basic captcha in C#.net PinmvpSandeep Mewara28-Feb-13 6:29 
GeneralRe: Create a basic captcha in C#.net PinmemberMember 870181328-Feb-13 7:02 
GeneralRe: Create a basic captcha in C#.net PinmvpSandeep Mewara28-Feb-13 7:23 
GeneralRe: Create a basic captcha in C#.net PinmemberMember 870181328-Feb-13 7:28 
GeneralRe: Create a basic captcha in C#.net PinmemberMember 870181328-Feb-13 7:24 
GeneralRe: Create a basic captcha in C#.net PinmemberMember 870181328-Feb-13 7:29 
AnswerRe: Create a basic captcha in C#.net PinmemberAshishChaudha28-Feb-13 18:11 
Questionthreaded function to send email, file io crashes Pinmemberjkirkerx27-Feb-13 9: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 10:30 
GeneralRe: threaded function to send email, file io crashes Pinmemberjkirkerx27-Feb-13 12:28 
AnswerRe: file io crashes PinmemberDavid Mujica27-Feb-13 11:40 
QuestionTextArea value in C# Pinmembervanikanc27-Feb-13 9:03 
AnswerRe: TextArea value in C# PinmvpSandeep Mewara27-Feb-13 19:12 
GeneralRe: TextArea value in C# PinmemberAli Al Omairi(Abu AlHassan)27-Feb-13 21:09 
GeneralRe: TextArea value in C# PinmvpSandeep Mewara27-Feb-13 22:02 
GeneralRe: TextArea value in C# PinmemberAli Al Omairi(Abu AlHassan)27-Feb-13 23:03 
GeneralRe: TextArea value in C# PinmvpSandeep Mewara28-Feb-13 0:16 
AnswerRe: TextArea value in C# PinmemberAli Al Omairi(Abu AlHassan)27-Feb-13 21:06 
GeneralRe: TextArea value in C# Pinmembervanikanc28-Feb-13 3:38 
GeneralRe: TextArea value in C# PinmemberAli Al Omairi(Abu AlHassan)4-Mar-13 5:13 
QuestionDataset Issue PinmemberAbhismart5527-Feb-13 4:18 
AnswerRe: Dataset Issue PinmemberAbhismart5527-Feb-13 8:15 
QuestionProblems with display image byte() on image tag Pinmemberkeidash27-Feb-13 1:36 
AnswerRe: Problems with display image byte() on image tag PinmemberAli Al Omairi(Abu AlHassan)4-Mar-13 4:26 
Questionwhy team is not replyin gmy question Pinmemberprince_rumeel27-Feb-13 0:13 

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
Web01 | 2.8.150414.1 | Last Updated 19 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid