473,381 Members | 1,509 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,381 software developers and data experts.

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 933

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

Similar topics

21
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
by: Web Developer | last post by:
Hi, Question: Why is there an inherent conflict between uncompromising efficiency and portability in C++? Regards WD
0
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
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
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
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
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
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.