By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,290 Members | 1,303 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,290 IT Pros & Developers. It's quick & easy.

Async to Sync

P: n/a
How can I make the following code synchronous? TIA.

Public Sub ValidateXMLAgainstSchema(ByVal XSchema As XmlSchema, ByVal XData
As String)

Dim XSchemaset As XmlSchemaSet = New XmlSchemaSet

XSchemaset.Add(XSchema)

Dim XSettings As XmlReaderSettings = New XmlReaderSettings

XSettings.ValidationType = ValidationType.Schema

XSettings.Schemas = XSchemaset

Dim xStringReader As StringReader = New StringReader(XData)

Dim XReader As XmlReader = XmlReader.Create(xStringReader, XSettings)

AddHandler XSettings.ValidationEventHandler, AddressOf ValidationCallBack

While XReader.Read

'If there are errors, an asynchronous call would be made to the

'ValidationCallBack sub. How can we make this synchronous, so this

'sub can be made a function which would return a boolean, or a collection

'of ValidationEventArgs that we could return?

End While

End Sub

Private Shared Sub ValidationCallBack(ByVal sender As Object, ByVal e As
ValidationEventArgs)

MessageBox.Show("Error occurred. " & e.Message, "Validation Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)

End Sub
Feb 13 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
DWS
Async,

I did that this morning found it somewhere don't remember, maybe you can
help with this delima since your working with xml. I can't get treeview to
work with xmldatasource when I have xmlns attribute in the xmlfile.

private _valid as boolean
Private Sub ValidationCallBack(ByVal sender As Object, ByVal e As
ValidationEventArgs)
_valid = False
End Sub

Public Function ValidateXMLAgainstSchema(ByVal XSchema As XmlSchema, ByVal
XData As String) as boolean
_valid = true
....
same code as in sub validatexmlagainstschema
....
return _valid
end function

It appears to be working for me but no guarantees.
Good Luck
DWS
"OpticTygre" wrote:
How can I make the following code synchronous? TIA.

Public Sub ValidateXMLAgainstSchema(ByVal XSchema As XmlSchema, ByVal XData
As String)

Dim XSchemaset As XmlSchemaSet = New XmlSchemaSet

XSchemaset.Add(XSchema)

Dim XSettings As XmlReaderSettings = New XmlReaderSettings

XSettings.ValidationType = ValidationType.Schema

XSettings.Schemas = XSchemaset

Dim xStringReader As StringReader = New StringReader(XData)

Dim XReader As XmlReader = XmlReader.Create(xStringReader, XSettings)

AddHandler XSettings.ValidationEventHandler, AddressOf ValidationCallBack

While XReader.Read

'If there are errors, an asynchronous call would be made to the

'ValidationCallBack sub. How can we make this synchronous, so this

'sub can be made a function which would return a boolean, or a collection

'of ValidationEventArgs that we could return?

End While

End Sub

Private Shared Sub ValidationCallBack(ByVal sender As Object, ByVal e As
ValidationEventArgs)

MessageBox.Show("Error occurred. " & e.Message, "Validation Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)

End Sub

Feb 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.