473,480 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Will I have a thread conflict with this?

I'm still trying to wrap muy head around preventing thread conflicts. I have
a class that has two functions in it. This is called from various part of my
application and will generate a XML file. I've gotten lots of advice on
this, and am looking for a check on where I'm at. Am I missing some
concepts. Prior to this, I was using synclock to lock a filestream, however,
this time I'm not writing to a file, so not sure if I need a synclock or
not.

My concen is if the first function is called, and starts running the second
function while the first is called by another thread...would that lead to
the second function sending the wrong data back?

Public Class menuWriterToDB

Shared Sub createXMLfileWithXmlWriter(ByVal parentNode As Integer, ByVal
intLevel As Integer, ByVal siteID As Integer)

Try

Dim sbXML As New System.Text.StringBuilder
Dim swXML As New System.IO.StringWriter(sbXML)
Dim twXML As New System.xml.XmlTextWriter(swXML)

twXML.Formatting = twXML.Formatting.Indented
twXML.Indentation = 3
twXML.WriteStartDocument()
twXML.WriteComment("Created on " & Now())
twXML.WriteStartElement("menuItems")

' this calls the other function to begin the recursive DB call and
building of the XML
WriteXmlData(twXML, parentNode, siteID)

twXML.WriteEndElement() 'close menuItems node
twXML.WriteEndDocument() 'close docment

'create a DB connection and save the XML (sbXML.ToString) into it

twXML.Flush()
twXML.Close()

Catch ex As Exception
' catch errors
Finally
End Try
End Sub

Shared Sub WriteXmlData(ByVal objXMLWriter As System.Xml.XmlTextWriter,
ByVal parentNode As Integer, ByVal siteID As Integer, Optional ByVal
intLevel As Int32 = 0)

' grab all the data from the DB...

While rowCount < DS.Tables(0).Rows.Count 'ie, if there IS data,
then...
objXMLWriter.WriteStartElement("menuItem")

' write out all the nodes...
objXMLWriter.WriteElementString...

'now call the subroutine we're in to see if this value has
'any children and increase the indent, and so on...
WriteXmlData(objXMLWriter,
Convert.ToInt32(DS.Tables(0).Rows(rowCount).Item(0 )), siteID, intLevel + 1)

rowCount = rowCount + 1
End While

' clean up
objConnect.Close()
objOleDbAdapter.Dispose()
objCommand.Dispose()
End Sub
End Class
May 25 '06 #1
0 935

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
3880
by: Rabbit63 | last post by:
Hi: I want to show a set of records in the database table on the clicnt browser. I have two ways to do this (writen in JScript): 1.The first way is: <% var sql = "select firstname from...
12
3457
by: Web Developer | last post by:
Hi, Question: Why is there an inherent conflict between uncompromising efficiency and portability in C++? Regards WD
0
261
by: dls | last post by:
Whenever I start VS.NET (1.0) the MSI installer runs to configure Outlook 2002. Is there a conflict here? Outlook 2002 seems to run ok.
2
3727
by: Mark | last post by:
This seems to be another ploy by Microsoft to push the competition out. Why in the world would MS pick a file extension of .PDB for their DotNet project files, when Palm has been using this file...
3
3239
by: Mike Ridley | last post by:
I have 2 databases called (for example) "progs.mdb" and "files.mdb". Both these databases reside on computer "myserver". The progs database has links to the tables in the files database....
2
3008
by: Darrel | last post by:
I'm working on an app where the ASPX pages aren't precompiled with the class.vb files I'm. This is so people can add their own ASPX pages down the road to the app (the .aspx pages become...
2
1798
by: awalter1 | last post by:
Hello, I'm developping an application with python, pyGTK and GTK+. I've performed many tests by using methods as Popen, popen2, os.system ... to communicate with Unix (HPUX), The last attempt...
1
986
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
When I define id attribute for both parent and child nodes, I get error of conflict. For example, the following is invalid: <parent id="1"> <child id="1">Name 1</child> <child id="2">Name...
0
1695
by: Miles | last post by:
On Mon, Sep 15, 2008 at 6:06 AM, Harish K Vishwanath <harish.shastry@gmail.comwrote: "built-in type" generally means "implemented in C", also sometimes called "extension type". Both the...
0
7037
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7032
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4767
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.