Is SynchronizationContext.Post() threadsafe?

Posted by cyclotis04 on Stack Overflow See other posts from Stack Overflow or by cyclotis04
Published on 2010-05-18T18:13:14Z Indexed on 2010/05/18 19:40 UTC
Read the original article Hit count: 344

This is a pretty basic question, and I imagine that it is, but I can't find any definitive answer. Is SynchronizationContext.Post() threadsafe?

I have a member variable which holds the main thread's context, and _context.Post() is being called from multiple threads. I imagine that Post() could be called simultaneously on the object. Should I do something like

lock (_contextLock) _context.Post(myDelegate, myEventArgs);

or is that unnecessary?

Edit:
MSDN states that "Any instance members are not guaranteed to be thread safe." Should I keep my lock(), then?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET