If the block is loked, does the other user request wait for realease of lock?
Yes。So if a user uses too much time to deal with the xml file,I'm afraid it will take much time to wait……
So I suggest you can create another static class,with a static constructor to read all the xml contents out (if possible,you can use DataSet.ReadXml to convert the xml contents into the form of DataTable……;and then expose the property for others to view
for read-only thing……)。
If the block is loked, does the other user request wait for realease of lock?
Yes。So if a user uses too much time to deal with the xml file,I'm afraid it will take much time to wait……
So I suggest you can create another static class,with a static constructor to read all the xml contents out (if possible,you can use DataSet.ReadXml to convert the xml contents into the form of DataTable……;and then expose the property for others to view
for read-only thing……)。
To solve this issue, we panned to remove all static classes and static objects and replace with LINQ to XML concepts.
Of course this is a nice way……and in my mind,I think if you use static class for reading all the contents of xml into memory for ONLY first time and show to the public,it will in fact save memory and energy……For static constructor can be only exeucted once。I'd
like to know why you use LINQ-TO-XML to readl xml contents again and again when each client accesses the web page instead of reading them all once?
We have multiple xml files. depond on user request, files should be loaded.
Decker Dong - MSFT
saffy
To solve this issue, we panned to remove all static classes and static objects and replace with LINQ to XML concepts.
Of course this is a nice way……and in my mind,I think if you use static class for reading all the contents of xml into memory for ONLY first time and show to the public,it will in fact save memory and energy……For static constructor can be only exeucted once。I'd
like to know why you use LINQ-TO-XML to readl xml contents again and again when each client accesses the web page instead of reading them all once?
saffy
Member
304 Points
365 Posts
Best way to read XML file.
Jan 25, 2012 08:13 AM|LINK
Hi,
We are facing "file used by another process" error while reading xml file. (we used XmlDocument Class to read xml file.)
Generally this happens when more number of users try to access the same file.
Even we have set null to XmlDocument object, after reading the file.
Can you suggest a best way to handle this.
MetalAsp.Net
All-Star
112051 Points
18235 Posts
Moderator
Re: Best way to read XML file.
Jan 25, 2012 09:50 AM|LINK
saffy
Member
304 Points
365 Posts
Re: Best way to read XML file.
Jan 25, 2012 10:55 AM|LINK
Yes. its for ASP.NET application using c#
kuber.manral
Contributor
3051 Points
714 Posts
Re: Best way to read XML file.
Jan 25, 2012 11:37 AM|LINK
Hi,
I believe you should use lock for this purpose. Before start reading XML file, put a lock there. Like :
lock(this)
{
// Do your work here
}
Try this and Let us know the results..
<div class="mcePaste" id="_mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;"></div>Visit My Blog
saffy
Member
304 Points
365 Posts
Re: Best way to read XML file.
Jan 25, 2012 12:07 PM|LINK
Hi,
Thank u for your reply.
Will implement the same and get back.
If the block is loked, does the other user request wait for realease of lock?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Best way to read XML file.
Jan 27, 2012 12:29 AM|LINK
Yes。So if a user uses too much time to deal with the xml file,I'm afraid it will take much time to wait……
So I suggest you can create another static class,with a static constructor to read all the xml contents out (if possible,you can use DataSet.ReadXml to convert the xml contents into the form of DataTable……;and then expose the property for others to view for read-only thing……)。
Reguards!
saffy
Member
304 Points
365 Posts
Re: Best way to read XML file.
Jan 27, 2012 07:27 AM|LINK
Thank you for your reply.
Will get back after implementing.
saffy
Member
304 Points
365 Posts
Re: Best way to read XML file.
Jan 30, 2012 08:32 AM|LINK
Hi,
To solve this issue, we panned to remove all static classes and static objects and replace with LINQ to XML concepts.
For basic testing we are able to solve 50% of our issues.
we are working on it. will get back.
Can u suggest any best way to proceed.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Best way to read XML file.
Jan 30, 2012 11:49 PM|LINK
Of course this is a nice way……and in my mind,I think if you use static class for reading all the contents of xml into memory for ONLY first time and show to the public,it will in fact save memory and energy……For static constructor can be only exeucted once。I'd like to know why you use LINQ-TO-XML to readl xml contents again and again when each client accesses the web page instead of reading them all once?
Reguards!
saffy
Member
304 Points
365 Posts
Re: Best way to read XML file.
Jan 31, 2012 08:05 AM|LINK
Hi,
Thanks for reply.
We have multiple xml files. depond on user request, files should be loaded.