The difference between the observer pattern and the event

Source: Internet
Author: User

If there is a form, there is a timer

b form, there is also a timer.

Requires that the B form's timer and a form be synchronized.

A form is the main interface and the B form is a sub-interface

Scenario 1: To keep the B-form and the A-form synchronized timers, you can pass the interval of the A-form's timer as a parameter to the B form's constructor when you start the B form

Or save an interval of form A to a file, read from the configuration after the B form is loaded

Then, when the a form changes the interval of the timer, the B form is notified by the event.

Scenario 2: You can implement the observer pattern, passing the interval directly through the observer pattern when instantiating the B form. And when changing the A-form timer interval, all observers are notified by the OnNext method, and the timer acquisition interval changes.

The difference between the observer pattern and the event

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.