C # imitating QQ and MSN message Series 4. Optimized bug Modification

Source: Internet
Author: User
Tags high cpu usage

 

C # imitating QQ and MSN message series I. Basic Principles

C # imitating QQ and MSN message Series 2. imitating the basic effect includes code

C # imitating QQ and MSN message Series 3. Achieving multiple prompts

C # imitating QQ and MSN message Series 4. Optimized bug Modification

C # imitating QQ and MSN message Series 5. Using only two time controls for improvement

 

1. modify content

1. error message for referencing the mail category

Cause: the point attribute belongs to the reference mail class.

Modification method:

Originally, the public point endpoint is used. The attribute is used to obtain the location where the next Prompt window appears.

 

Public   Int Y
{
Get { Return   This . Endpoint. Y ;}
}

 

Problem Solving

 

2. Each time when multiple prompts pop up, the height of each window from the second start is 2 pixels higher than that of the background.

Cause: the default value of Form height is 2.

So we have to wait until the form moves two pixels and start to synchronize the position and size of the form.

 

If ( This . Movecount >   2 )
{
This . Height ++ ;
}

 

3. High CPU usage when multiple windows are displayed at the same time

Cause: it may be a problem with the system. Windows. Forms. Timer control.

Replace all the controls with system. Threading. Timer.

Result: The problem is not solved, and sometimes an exception occurs when multiple threads call the form (the probability is not high)

 

Continue waiting for the cool to solve this problem

 

Ii. Induction of knowledge points

After completing this demo, you can learn the following knowledge points:

1. operating principle of Form position

2. Mutual call between windows

3. Usage of system. Threading. Timer includes start and end

4. asynchronous thread operation window content (you must write the invoke method for calling delegate and related controls)

 

Iii. Function summary and overall

1. implement multiple prompts and automatically determine the location of the next form based on the current active form

2. Hover the mouse over the form. When the mouse is over the form, the form stops motion and continues the current action after it leaves.

 

 

: WindowsMoveDemo2008-07-30.rar

 

 

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.