. NET Compact framework BASICS (9)

Source: Internet
Author: User

Before reading this article, you 'd better take a look at it first.. NET Compact framework BASICS (1)This articleArticle.

What we want to talk about today is an extension in the above section. In this article, we will mention the systemstate class.
This class is mainly used to collect and monitor many status information of the system.

Today, we will introduce another feature. When the monitoring conditions are met, start the application.Program.
Why? For example, if you set a monitoring rule and let the system handle it by yourself, once the condition is triggered, the corresponding program will be called immediately.
Scenario: When I receive 100 unread messages, I immediately delete the read messages in my inbox.

The following describes how to use this method.
Create a systemstate class to tell it what to monitor

1 Private Systemstate state;
2
3 Private   Void Form1_load ( Object Sender, eventargs E)
4 {
5 // Number of unread SMS messages
6 State =   New Systemstate (systemproperty. messagingsmsunread );
7 // Comparison Method
8 State. comparisontype = Statuscomparisontype. Greater;
9 // Comparison Value
10 State. comparisonvalue =   100 ;
11 }

 

Start System Monitoring:

1 Private   Void Menuitem3_click ( Object Sender, eventargs E)
2 {
3 // Tell it applicationid. You can also add the path to start the application.
4 State. enableapplicationlauncher ( " Devautostartdemo " );
5 }

 

Cancel System Monitoring:

1 Private   Void Menuitem4_click ( Object Sender, eventargs E)
2 {
3 State. disableapplicationlauncher ();
4 }

 

Once the system monitoring is started[HKEY_LOCAL_MACHINE \ SYSTEM \ notifications].
This directory records key values to describe the application path.

See the following results:
Start the program, enable is start, disable is cancel

Close the program and check the number of unread messages in the current system.

No unread text message. Check the registry.

The Registry has been inserted into this directory, indicating that the system monitoring has been registered.

Send a text message to test the effect.

Indicates that the program has been triggered.

CodeDownload:Devautostartdemo.rar

Author: appleseeker

Date: 2008-09-21

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.