Link to home
Start Free TrialLog in
Avatar of EfrenM
EfrenMFlag for United States of America

asked on

VB .net XML parser not closing

Hi All
so my piece of code is working however, lets say it is reading the xml and there are repeating tables it will get the info and wait until i click a checkbox to show me the rest, here is the problem lets say the xml document has 4 repeating tables and i close the app on the second one
the app GUI closes but it is still running in the back ground. any ideas how i can make it complety close?
Try

            Dim m_xmld As XmlDocument
            Dim m_nodelist As XmlNodeList
            Dim m_node As XmlNode
            'Create the XML Document
            m_xmld = New XmlDocument()
            Dim mgr As New XmlNamespaceManager(m_xmld.NameTable)
            'Load the Xml file
            m_xmld.Load(textboxFileToOpen.Text)
            mgr.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-12-29T14:17:33")
            'Get the list of name nodes 
            m_nodelist = m_xmld.SelectNodes("//my:group2", mgr)
            'Loop through the nodes
            For Each m_node In m_nodelist

                'Get the firstName Element Value
                Dim lastNameValue = m_node.ChildNodes.Item(0).InnerText
                'Get the lastName Element Value
                Dim firstNameValue = m_node.ChildNodes.Item(1).InnerText
                Dim companyname = m_node.ChildNodes.Item(2).InnerText
                Dim description = m_node.ChildNodes.Item(3).InnerText
                Dim emailaddy = m_node.ChildNodes.Item(4).InnerText
                Dim memberof = m_node.ChildNodes.Item(5).InnerText
                Dim primarygroupid = m_node.ChildNodes.Item(6).InnerText
                Dim manager = m_node.ChildNodes.Item(7).InnerText
                Dim department = m_node.ChildNodes.Item(8).InnerText
                Dim password = m_node.ChildNodes.Item(9).InnerText
                'Write Result to the Console
                'MsgBox("FirstName: " & firstNameValue & " LastName: " _
                ' & lastNameValue & " Company Name: " & companyname & " Desc: " & description & " Email Addy: " & emailaddy)
                '  Console.Write(vbCrLf)
                textboxlastName.Text = lastNameValue
                textboxfirstName.Text = firstNameValue
                textboxcompanyName.Text = companyname
                textboxDescription.Text = description
                textboxEmailAddress.Text = emailaddy
                'TextBoxmemberof.text = memberof
                'textboxprimarygroup.text = primarygroupid
                textboxManager.Text = manager
                textboxDepartment.Text = department
                textboxPassword.Text = password
               
         
                checkboxnext.Checked = False


                Do Until checkboxnext.Checked = True
                    Threading.Thread.Sleep(1000)
                Loop

            Next

        Catch errorVariable As Exception
            'Error trapping
            MsgBox(errorVariable.ToString())
        End Try

Open in new window

Avatar of kaufmed
kaufmed
Flag of United States of America image

Is this a multi-threaded app? Are you using any sort of Thread, BackgroundWorker, or ThreadPool objects elsewhere to run the above code?
ASKER CERTIFIED SOLUTION
Avatar of wdosanjos
wdosanjos
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of EfrenM

ASKER

@kaufmed: yes it has threads Private Pause As New Threading.ManualResetEvent(True)

@wdosanjos: it worked on my context menu below is the code, any idea how to make it detect when i press the X button on the top right hand side?


Private Sub TestToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TestToolStripMenuItem.Click
        isAppClosing = True
        Application.Exit()
    End Sub

Open in new window

Avatar of EfrenM

ASKER

duh i got

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        isAppClosing = True
        Application.Exit()
    End Sub

Open in new window

Avatar of EfrenM

ASKER

thank you, saved me a headache :)
You can handle that on the form's FormClosing event.