473,545 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
+ 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 createXMLfileWi thXmlWriter(ByV al parentNode As Integer, ByVal
intLevel As Integer, ByVal siteID As Integer)

Try

Dim sbXML As New System.Text.Str ingBuilder
Dim swXML As New System.IO.Strin gWriter(sbXML)
Dim twXML As New System.xml.XmlT extWriter(swXML )

twXML.Formattin g = twXML.Formattin g.Indented
twXML.Indentati on = 3
twXML.WriteStar tDocument()
twXML.WriteComm ent("Created on " & Now())
twXML.WriteStar tElement("menuI tems")

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

twXML.WriteEndE lement() 'close menuItems node
twXML.WriteEndD ocument() '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(By Val objXMLWriter As System.Xml.XmlT extWriter,
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).Ro ws.Count 'ie, if there IS data,
then...
objXMLWriter.Wr iteStartElement ("menuItem")

' write out all the nodes...
objXMLWriter.Wr iteElementStrin g...

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

rowCount = rowCount + 1
End While

' clean up
objConnect.Clos e()
objOleDbAdapter .Dispose()
objCommand.Disp ose()
End Sub
End Class
May 25 '06 #1
0 937

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

Similar topics

21
3889
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 table1"; var obj=new ActiveXObject("ADODB.Recordset");
12
3465
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
3735
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 extension for years! As a consequence to "us" consumers, who also use Palm OS devices, we now have to redefine our file extension of PDB to be Palm...
3
3249
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. "myclient1" runs a shortcut "msaccess.exe \\myserver\progs.mdb /x startmacro". "myclient2" runs his shortcut "msaccess.exe \\myserver\progs.mdb /x...
2
3015
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 'templates' in a way). As such, each template has a function call at the top: <% retrieveData() %> and then within the page, wherever they want to show...
2
1802
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 is this code written in a thread : fin,fout = popen2.popen2('ps -def') line = fin.readline() while 1 : if not line : break
1
992
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 2</child> </parent> Questions: (1) If I do want to use id for both of them, how can I do? (2) How can I read the attributes from DOM?
0
1707
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 Exception and ZODB Persistent objects are implemented in C, and they have different ideas for the format of the struct that holds an object's data. It...
0
7487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7420
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7446
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5349
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4966
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
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 we have to send another system

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.