Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

using System.Windows.DependencyObject.GetValue method, there is a error "The calling thread can't access the object, because another thread with the object"

$
0
0

when i use the method System.Windows.DependencyObject.GetValue, there is a error "The calling thread can't access the object, because another thread with the object", I do not use WPF , so I do not know why, is anyone have this problem once? Thanks.

I use the method as following:

public static readonly DependencyProperty NameProperty =
            DependencyProperty.Register("Name", typeof(string), typeof(ViNamedObject),
                                        new FrameworkPropertyMetadata(string.Empty));

        public string Name
        {
            get
            {
                string result;
                try
                {
                    result = (string)GetValue(NameProperty);
                }
                catch (Exception)
                {
                    
                    throw;
                }
                return result;
                //return (string)GetValue(NameProperty);
            }
            set
            {
                if (string.IsNullOrEmpty(value))
                    ClearValue(NameProperty);
                else
                    SetValue(NameProperty, value);
            }
        }

<link href="chrome-extension://bicdefpoleoohkhgcbbhambpghigfeid/build/index.css" rel="stylesheet" />


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>