.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Is XpathDocument thread safe?!? (FileShare.Read access?)

Posted By:      Posted Date: October 16, 2010    Points: 0   Category :ASP.Net

if you  have a private void function inside of main page of system.web.page.ui

            XPathNavigator nav;
            XPathDocument docNav;
            XPathNodeIterator NodeIter;
            docNav = new XPathDocument(@"D:\data\data.xml");
            nav = docNav.CreateNavigator();

and multiple users are now on the web application simultaneously using nav object, will it be thread safe?  In filestream, the solution was to use FileShare.Read parameter.  but does xpathdocument have something similar?


View Complete Post

More Related Resource Links

.NET Column: Safe Thread Synchronization


By far, the most common use of thread synchronization is to ensure mutually exclusive access to a shared resource by multiple threads. In the Win32® API, the CRITICAL_SECTION structure and associated functions offers the fastest and most efficient way to synchronize threads for mutually exclusive access when the threads are all running in a single process.

Jeffrey Richter

MSDN Magazine January 2003

"Read Only" Access Error when checking in documents from outlook



We are accessing our sharepoint services 3.0 document library through outlook 2007.

We can open the files in word/excel etc, but when we go to check-in the document the application tells us that we only have read access to the document, and cant check the document back in to the server.

It works fine via the browser, the read only problem is only when checking out through outlook.

I have given all users full access and design access to the doc library.

Any help would be greatly appreciated.






Merge Replication: How to give read access on snapshot share to a sql account

Hello All, I want to give read access to an sql account(not windows account). Can it be given or not. Someone please tell. Thanks saandii777

Task assignment to user without read access in 2007 results in no email to assignee, no warning to a

It appears (from observation and searching) that SP 2007 will not send a task assignment email when the assignee does not have read access for the assigned task and there is no warning when assigning a task to someone who will be unable to read it. I have not been able to find any mentions of attempting to address this quirk by either an item event listener or a workflow that would either prevent the assignment or task the originating user to fix the issue by either changing the assignment or having them added to the appropriate group.  I could see one done badly causing a cascade of tasks. The approaches that I've thought about are: Attempt to block assignment by hooking ItemAdding and ItemUpdating on the task content type.  In ItemUpdating, you could use SPListItem.DoesUserHavePermissions since the SPListItem should be there, but you'd may have check the list since I don't think SPListItem is available at that time.  I could see this causing problems when the assignment is via workflow or something that doesn't like other code interfering with its task creation. Hooking ItemAdded and ItemUpdated to assign a new task to the assigning user to either change the assignment or have the assignee added to the users with access to the site. Define a workflow which could be enabled for a list that would check if any new or modified task is assigned to users with

ThreadPool with lock isn't thread safe

Hello, I'm having some problems with my code which apparently isn't thread safe at all. The problem is that it doesn't crash often, but of course it does when in production! I have twisted my mind around the problem for a month or so now, and I need some help in sorting out the problem. Well, the problem is that it isn't thread safe, and the collection (_subscribers) is modified while looping. The error says that it crashes in the method: SendRoundSettings. Here's part of the code (which I guess contains the error, as the other methods are pretty much identical): [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)] public class DuplexService : IDuplexService { private readonly object _syncRoot = new object(); private static Subscribers _subscribers = new Subscribers(); private static RoundSettings _currentRoundSettings = new RoundSettings() {CompetitionId = 1, NumberOfAthletesInRound = 0, Round = 0, SortDirection = SortDirection.ByStartNumber}; public void SendJudgeScore(CompetitionJudgeAthleteJump judgeScore) { ThreadPool.QueueUserWorkItem(state => { Subscribers clonedSubscribers = CloneSubscribers(); Console.WriteLine("Sending judgeScore to {0} client(s)", clonedSubscribers.Count(x => x.CompetitionId == judgeScore.CompetitionId));

MDX to read members from "restricted access" role

Is it possible to read list of members from "restricted access" roles? I want an MDX so we can create an exception report for maintance purposes to match this list with some other list. I only need to list what I see when I open "resticted access" role - domains with user names. thank you!

C# Thread Safe Class events

Right now I have created a custom base class that has numerous events.  These events have non-standard signatures and are fired from a thread I have that is basically just a while loop checking variables against older ones for telling when something has changed. As far as I know this is the best way to go about doing this is to just make a void on another thread in a while (true) loop, in the loop just doing ifs... than doing a thread sleep.  I make sure the thread is a background thread that way it'll exit propertly when the consumer exits.  If anyone knows a beter way of going about this than stop reading here. :) If not that onto my real question... I have events that are fired from this loop on the thread I created, now they're attatched on the consumer app and no matter what I do I can't seem to get these events to be thread-safe so that I don't have to use the Control.Invoke method for each event. If anyone knows anything that'll help me out it'll be much appreciated. Thanks,Chad

The calling thread cannot access this object because a different thread owns it.

this is my code I want to put the win.show in another thread but win object in the main thread. because I need to do some verification to the win.content in main thread when the win ui is refreshing in another thread. however, I hit the exception The calling thread cannot access this object because a different thread owns it.   namespace ConsoleApplication1 {     public delegate void AsyncDelegate();     public class Program     {                 [STAThread]         static void Main(string[] args)         {             Window win = new Window();                        AsyncDelegate call = new AsyncDelegate(()=>win.Show());             call.BeginInvoke(null, null);                     }             }     }

Equivalent C# function for this random access read for this VB6 function?

I'm having a problem reading a block of bytes into an array from a file read (random access).  Instead, in C#, it seems I can only read byte by byte and not a block of byte.  I want to create a string array that is 500 cells in capacity but each cell is 10 bytes wide.  how do i do this?I have  written the function in Vb6 and maybe someone can tell me the fs.Read (code) for the C# equivalent.In Vb6, I declaredPrvate Type WFM  points(500) as String * 10   // This will create an string array of 500 cells but the KEY here is each cell is 10 bytes wide fixed!End type

What do I have to do to allow users read access to the cube?


(SQL 2005)

I'll try asking this again since I'm still not able to access my data cube. 

I've developed a BI solution with SSIS, SSRS and SSAS.  The account I've used for development has had Domain Administrator permissions and I've never had a problem running an SSRS report that reads the cube.  When I use an account with less than Domain Admin permissions and try to run a SSRS report that runs a query against a SSAS cube the query fails.

I've set up a Domain User group and given it read access to the data sources in Report Manager.  I've given the group datareader role in ReportServer and ReportServerTempDB as well as the DataReader role in the SSAS cube.

Why can't I read any data from the cube???

Are non-static objects thread-safe in a static-method?


I am using javascript and ajax to call server side mothod.  The pagemethod can only be static function in teh server side.  But i know static methods are not thread safe across simultaneous sessions.  However, what if the static method is modifying a non-static object?

for example:

public partial class default : system.web.ui.page

Hero Superman; // create an object called superman of class hero for all user sessions independently

public static int(newpowers)


Superman.powers = newpowers;  // Is this thread safe?  Will each user not accidentally get written by another user's power values?


web service thread-safe?



I am using a COPY web service. Is the function that uploads a document, COPYINTOITEMS, a thread-safe? If not, what is a good way to do a similar thing?

I am thinking to create one copy object and all incoming requests(thread) share this object to invoke CopyIntoItems function.

Thank you.

Is Dispatcher.BeginInvoke really NOT thread safe, while the old System.Windows.Forms.Control.BeginIn




System.Windows.Forms.Control.BeginInvoke is documented as thread safe (in fact, BeginInvoke , EndInvoke , Invoke , InvokeRequired , and CreateGraphics are).



But in WPF, Dispatcher.BeginInvoke is not documented as thread safe. Which would appear to me as a regression (and not really convenient, to be honest).

Was it only forgotten in MSDN documentation, or should I really use external locking to prevent the dispatcher to get lost in its messages and priorities?



Thanks. ;)

TCPClient and Read not returning complete data unless I use thread.sleep


Hello experts, here is my code that I have a question on:

 Dim receivedbyte(1024) As Byte
        Dim myread As Integer = 0
        Dim myresponsesb As New StringBuilder()
            myread = myns.Read(receivedbyte, 0, receivedbyte.Length)
            myresponsesb.Append(System.Text.Encoding.UTF8.GetString(receivedbyte, 0, myread))

        Loop While (myns.DataAvailable)

In the above, myns is a networkstream that is initialized with a tcpclient that is communicating with a XMPP server. basically, iam getting back xml messages.

The issue with the above is that if I dont use thread.sleep(500), the complete data is not returned. Why is that? I have tried to use a streamreader instead of read and using that method i can get complete data from the stream. What am I doing wrong with the Read method of networkstream?

SECOND: The XML being returned from the server is not well formed - the closing tag for one of the tags is missing and I am unable to use XDocument to parse this XML because of this. What could be the issue here? Is it my code or something on server end?

Also, what technique should i use to make the returned XML well formed so that I can use XDOCUMENT and LINQ to parse this?


TreeView in Web Part required webctrl_client folder to have atlease read access for all users


HI All

I am using the TreeView control from the Microsoft.Web.UI.WebControls Namespace to render a treeview in a SharePoint web part. The tree nodes images do not appear (text is rendered) properly until i grant atleast read permissions to Authenticated Users on the webctrl_client folder which has to be places in the web application's virtual directory.

Is there some way I can avoid granting the read permission on that folder to all authenticated users.

If i go ahead with the approach of giving the authenticated users rad permission, will a user loggedin via FBA get the read permission

Thanks in Advance

how to access a thread from other then the one it created.



am using the above code line to make a thread call within another thread in .net 3.5 compact framework project.
I keep getting the following error
Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.

How do i get rid of this error. Please help

Thanks in advance

Broken Images for Users with Read access



we just have moved our existing sharepoint team site to an extranet site and ran into a strange issue with images. Two of the images on our extranet site does not show up for users with Read access .They see little red "x" instead.  It only happens for two images not for all.

All images were added in Publishingimages or images folder and the library does inherit permissions from the main site.

any thoughts

Isha kapoor My SharePoint Blog Follow me
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend