[Mono-dev] Bug in Dispatcher.cs VerifyAccess or am I confused on the mono threading model?

Brad Cunningham brad at bradcunningham.net
Mon Apr 4 20:54:24 EDT 2011


I just upgraded to 2.10 and am getting strange behavior that I wasn't seeing
in 2.8.1

I call VerifyAccess in my code which is the method in the Dispatcher class
that will compare the calling thread with the thread that the dispatcher was
created on, if they differ it will throw an exception. In 2.8.1 it seemed
that the Dispatcher object was always null so I never called these methods.

In 2.10 it seems the Dispatcher is no longer null so I am making it into my
calls to VerifyAccess and it is throwing an exception:

System.InvalidOperationException: "The calling thread is not the same as the
creation thread"


a few things that are strange about this:

Prior to calling verify access I am doing some sanity checks
1. Dispatcher is not null
2. It's hash code matches the Thread.CurrentThreads hash code
3. Dispatcher.Thread == Thread.CurrentThread evaluates true

4. Looking at the code from the 2.10 branch for dispatcher this doesn't
appear to be the error text that should be thrown so I assume something else
is going on here.


That seems to tell me that they are in fact the same thread and the
exception should NOT be thrown. Since the error message doesn't seem correct
I assume something else is going on here that I don't understand.


Any ideas?




-- 
Brad Cunningham
Microsoft MVP: C#

http://blog.bradcunningham.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110404/8bf5a59e/attachment.html 


More information about the Mono-devel-list mailing list