Extreme performance problems with a repeating table -> C# / web

P

Pawel

Hi to all!!!!

I have a problem with performance of a template working in browser mode. It
seems that filling a repeating table using a XmlWriter is the case.

First I tried to fill like this:

foreach (DataRow row in dataTable.Rows)
{
string myNamespace = NamespaceManager.LookupNamespace("my");
using (XmlWriter writer =
MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1",
NamespaceManager).AppendChild())
{
writer.WriteStartElement("Values",
myNamespace);

writer.WriteElementString("Value1",
myNamespace, row["Value1"].ToString());
writer.WriteElementString("Value2",
myNamespace, row["Value2"].ToString());
writer.WriteElementString("Value3",
myNamespace, row["Value3"].ToString());
writer.WriteElementString("Value4",
myNamespace, row["Value4"].ToString());
writer.WriteElementString("Value5",
myNamespace, row["Value5"].ToString());

writer.WriteEndElement();
writer.Close();
}
}

While opening in browser after about half a minute a dialog box apper saying
that "A Scripts on this page is causing Internet Explorer to run slowly. If
it

continues to run, your computer may become unresponsive".

The InternetExplorer 7 has at this time OVER 0,5 gigs in the task
manager!!!!!!!! (The server an the client is up-to-date with all services
packs)


It seemed to me that AppendChild() method is the problem so I tried first to
generate the xml with the data to MemoryStream:

MemoryStream memoryStream = new MemoryStream();
XmlWriter memoryXmlWriter = XmlWriter.Create(memoryStream);

string myNamespace = NamespaceManager.LookupNamespace("my");

foreach (DataRow row in dtTasks.Rows)
{
memoryXmlWriter.WriteStartElement("Values", myNamespace);

memoryXmlWriter.WriteElementString("Value1", myNamespace,
row["Value1"].ToString());
memoryXmlWriter.WriteElementString("Value2", myNamespace,
row["Value2"].ToString());
memoryXmlWriter.WriteElementString("Value3", myNamespace,
row["Value3"].ToString());
memoryXmlWriter.WriteElementString("Value4", myNamespace,
row["Value4"].ToString());
memoryXmlWriter.WriteElementString("Value5", myNamespace,
row["Value5"].ToString());

memoryXmlWriter.WriteEndElement();
}

memoryXmlWriter.Flush();
memoryXmlWriter.Close();

string outStr = Encoding.UTF8.GetString(memoryStream.ToArray());

//Add "my:" and "/my:" prefix
string rtXml = AddPrefixMy(outStr);

And then replace directly repeating table InnerXml:

MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1",
NamespaceManager).InnerXml = rtXml;

While opening in browser nothing changes and the same dialog box appers.

Do you have any ideas how to optimize this code.

Thanks for ANY reply !!!!!!!!!!!!!!!
 
S

SSA

Make sure you are not running into an infinite loop. Test this code with
fewer records. It should work without any problem. If it doesnt then there is
a problem with your code. Performance issues occur only if your form is very
large and has lots of datasources and especially the datasources are not
defined properly in a hierarchical way. That is, if there is a text box
inside a section then the datasource of the text box should come inside the
datasource of the section. If not then it will affect the performance if you
have hundred datasources in your form not defined properly.

Pawel said:
Hi to all!!!!

I have a problem with performance of a template working in browser mode. It
seems that filling a repeating table using a XmlWriter is the case.

First I tried to fill like this:

foreach (DataRow row in dataTable.Rows)
{
string myNamespace = NamespaceManager.LookupNamespace("my");
using (XmlWriter writer =
MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1",
NamespaceManager).AppendChild())
{
writer.WriteStartElement("Values",
myNamespace);

writer.WriteElementString("Value1",
myNamespace, row["Value1"].ToString());
writer.WriteElementString("Value2",
myNamespace, row["Value2"].ToString());
writer.WriteElementString("Value3",
myNamespace, row["Value3"].ToString());
writer.WriteElementString("Value4",
myNamespace, row["Value4"].ToString());
writer.WriteElementString("Value5",
myNamespace, row["Value5"].ToString());

writer.WriteEndElement();
writer.Close();
}
}

While opening in browser after about half a minute a dialog box apper saying
that "A Scripts on this page is causing Internet Explorer to run slowly. If
it

continues to run, your computer may become unresponsive".

The InternetExplorer 7 has at this time OVER 0,5 gigs in the task
manager!!!!!!!! (The server an the client is up-to-date with all services
packs)


It seemed to me that AppendChild() method is the problem so I tried first to
generate the xml with the data to MemoryStream:

MemoryStream memoryStream = new MemoryStream();
XmlWriter memoryXmlWriter = XmlWriter.Create(memoryStream);

string myNamespace = NamespaceManager.LookupNamespace("my");

foreach (DataRow row in dtTasks.Rows)
{
memoryXmlWriter.WriteStartElement("Values", myNamespace);

memoryXmlWriter.WriteElementString("Value1", myNamespace,
row["Value1"].ToString());
memoryXmlWriter.WriteElementString("Value2", myNamespace,
row["Value2"].ToString());
memoryXmlWriter.WriteElementString("Value3", myNamespace,
row["Value3"].ToString());
memoryXmlWriter.WriteElementString("Value4", myNamespace,
row["Value4"].ToString());
memoryXmlWriter.WriteElementString("Value5", myNamespace,
row["Value5"].ToString());

memoryXmlWriter.WriteEndElement();
}

memoryXmlWriter.Flush();
memoryXmlWriter.Close();

string outStr = Encoding.UTF8.GetString(memoryStream.ToArray());

//Add "my:" and "/my:" prefix
string rtXml = AddPrefixMy(outStr);

And then replace directly repeating table InnerXml:

MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1",
NamespaceManager).InnerXml = rtXml;

While opening in browser nothing changes and the same dialog box appers.

Do you have any ideas how to optimize this code.

Thanks for ANY reply !!!!!!!!!!!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top