
|
You should have searched for it here at CP itself.
u said to search at CP...What is it & where is it
|
|
|
|

|
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
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
|
|
|
|

|
Not sure if it will help, but you can replace that entire block of code with:
Try
Dim strArray() As String = File.ReadAllLines(m_PhysicalPath)
Catch ex As Exception
m_html_Template = new StringBuilder
m_html_Template.Append("load_HTML_Template_Checkout_Complete general error")
dwExitCode = 1
End Try
http://msdn.microsoft.com/en-us/library/system.io.file.readalllines.aspx[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|

|
I'll give that a try.
I think my problem is with storing data in the heap, for the thread to access, and I changed some of the data in it.
So when I passed data to the function, inside the function I change the heap data and it crashed.
Which I now question, do I really need to pass data to a function within the thread, and just use the data I stored when calling the thread?
|
|
|
|

|
As crazy as it sounds, I've had problems with File IO and my solution was to introduce a sleep(1000) in the loop after closing the file. It worked for me.
Give it a shot.
|
|
|
|

|
Hi,
I have an HTML element defined as :
<textarea id="txtOrdersNotResult" runat="server" rows="5" cols="15" visible="false"></textarea>
when certain condition hold true, it triggers the textarea to be visible. Then it should set a value in this area, like
txtOrdersNotResult.Value = "this is a test"
I have also tried,
txtOrdersNotResult.InnerText = doesnotexist.ToString();
this area is empty.
any ideas?
|
|
|
|

|
You shared your requirement and not the issue you are facing while implementing it.
Now 2 things:
1. Don't use visible attribute. It will not even render the control and thus will not be accessible through JavaScript. Use style attribute 'display'
style="display:none", set it to display:block to show.
2. to set the value in it, use attribute value (starts with small V)
txtOrdersNotResult.value = "this is a test"
Hope both the tips should be enough for you to implement it.
|
|
|
|

|
I don't think he's talking about javascript, does he?
Help people,so poeple can help you.
|
|
|
|

|
Ali Al Omairi(Abu AlHassan) wrote: he's talking about javascript, does he?
Yes, he is. See the reference of InnerText (which clearly tells it's JS)
|
|
|
|