Autumn-style ad killer V2.5 released: sharing of various knowledge points

Source: Internet
Author: User

After more than a month, the new version V2.5 of autumn-style ad killer was finally released. Because there are few problems, the update cycle is longer.

 

Here we will talk about the content and knowledge points involved in this change:

1: removed the originally dependent Hosts mode, so the added, deleted, modified, and deleted the Hosts code.

2: In addition to the original Baidu search, the advertisement blocking function of Baidu knowledge page is increased.

3: added a server to provide the default service with a sword.

4: for the default proxy function, after layer-by-layer consideration, the software can open multiple ports in different directories to listen on different ports and become a multi-port proxy software.

The following are some of the things I remember during the upgrade:

 

1: The necessity of try catch for a thread:

First, let's talk about the dangers of thread exceptions:

1: winform program: The thread is abnormal. If not try, the software will automatically exit.

2: webform program: The thread is abnormal. If not try, the application pool will be restarted, similar to the website restart.

 

Summary:

Don't trust your control over the code too much. As long as it is a code function of the thread, try insurance is added. I can't escape such a level of errors. for software, stability is overwhelming.

 

2: knowledge points that the software can only start a single instance:

Sometimes, we only allow the software to start one instance, so we usually have such a common code check:

Static class Program {public static System. Threading. Semaphore _ mutex; // <summary> // main entry point of the application. /// </Summary> [STAThread] static void Main () {_ mutex = new System. threading. semaphore (1, 1, "adkiller"); if (_ mutex. waitOne (0, false) = false) {MessageBox. show ("the software has been started! "," Running prompt "); return;

}

}

}

 

It needs to be changed a bit: This upgrade needs to be enabled in different directories. Therefore, by logic, I wrote the following code:

Process cp = Process. getCurrentProcess (); Process [] allPros = Process. getProcessesByName (cp. processName); processCount = allPros. length; if (processCount> 1) {foreach (Process pro in allPros) {if (cp! = Pro & cp. MainModule. FileName = pro. MainModule. FileName) {MessageBox. Show ("the software has been started! "," Running prompt "); return ;}}

}

 

 

Two more knowledge points are involved:

1: problems during debugging:

During debugging, There Is A. vshost host by default. The software running after debugging is called: Autumn advertisement killer .vshost.exe

I want to test the running of software in multiple different directories, so I also run the software in other directories. The problem is:

The entire process is the autumn-style advertisement killer .vshost.exe.pdf and the direct-running autumn-style advertisement killer .exe.

Solution:

In this case, you only need to remove the check box of "Project-right-click Properties-debug-enable VS host process.

 

2: take it for granted errors:

The current Process object obtained by Process. GetCurrentProcess () will always be the same as the same Process object in the Process list, so we can compare and judge the object cp = pro.

Actual error:

Objects generated by Process. GetCurrentProcess are different from every pro object of the cyclic Process. Therefore, direct judgment is incorrect.

 

Of course there are a lot of error codes on the Internet:

At the beginning, I searched the internet and found a lot of code similar to the code I wrote. On the Internet, I used the = code to identify the error sample code. Everyone should pay attention to it.

Solution:

After careful discovery, the process ID is the same for the process, so I changed the judgment statement:

Cp. Id! = Pro. Id

The process ID is used to determine whether a process is the same.

 

Now, in this section, we will basically share these two smaller pieces of knowledge that are relatively remembered by me.

 

Software Upgrade: the system automatically upgrades the software after it is restarted.

Software: http://www.cyqdata.com/download/article-detail-54271

 

In addition, these 10 challenges have not yet been fully cracked, and everyone continues to do their best:Developer basic knowledge games, 10 in total, welcome to challenge

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.