Silverlight dispatcher class

Source: Internet
Author: User

Dispatcher Currently, only the non-user interface (UI) threads can be run on the UI.Code.

You can useDependencyobject.DispatcherAndScriptobject.DispatcherAttribute to access the UI threadDispatcherObject. These methods are instance methods, but these types of instances cannot be accessed frequently from non-UI threads. However, this applicationProgramOfDeploymentThe object isDependencyobjectAnd it canCurrentAttribute is used by any thread.

You can callCheckaccessMethod to Determine whether the caller is in the UI thread. If the caller is not in the UI thread, you can callBegininvokeTo run the specified delegate on the UI thread.

 private delegate void addtextdelegate (Panel P, string text); Private void addtext (Panel P, string text) {P. children. clear (); p. children. add (New textblock {text = text});} private void testbegininvokewithparameters (Panel p) {If (P. dispatcher. checkaccess () addtext (P, "added directly. "); else p. dispatcher. begininvoke (New addtextdelegate (addtext), P, "added by dispatcher. ") ;}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.