Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
355
Multi threaded carousel?
posted

I am attempting to programmatically remove items from the carousel listbox based upon other logic.  I am coding the logic using the "tag" property of the item that i also programmatically added at runtime.  When I attempt loop through the items and access the tag property i receive an error stating that "The calling thread cannot access this object because a different thread owns it".

I wanted to find out if this was caused by the carousel itself or something in my code.  So, far I can't find the problem in my code and was wondering if items added to the carousel were contained in their own thread(s).

Thanks.

Parents
  • 54937
    Offline posted

    DependencyObjects in WPF (which includes all elements/controls) are tied to the thread on which they are created. The implementation of GetValue method of DependencyObject (which is used to read the dependencyproperty value) calls VerifyAccess which ensures that you are calling the method on the thread in which it was created so you must be asking for the value of that property from a different thread than the one on which the element was created. Perhaps you're doing this from a timer that raises its tick on a separate thread or from the BeginInvoke of a Delegate.

Reply Children