Autumn ads Killer V2.5 Released: involving a variety of knowledge sharing

After more than a month, finally released a new version of the fall of ads Killer V2.5, because very seldom a problem, so update cycle will be longer.

 

Here to talk about some of the changes related to the contents and knowledge:

1: initially removed Hosts dependent mode, additions and deletions code Hosts are removed.

2: Baidu bid advertisements shield, in addition to the original Baidu search, Baidu knowledge to increase ad blocking page.

3: Added a server, the default sword out of the wall to provide services.

4: Default proxy, through layers of thinking that allows software when under different directories can be opened more, in a different listening port, into a multi-port agent software.


Here are several points to share knowledge upgrade, I remember being:

 

1: try catch the thread of necessity:

Let me talk about the dangers of thread exception:

1: winform program: Thread abnormal, if not try, cause the software to automatically exit.

2: webform program: Thread abnormal, if not try, cause the application pool restarts, similar sites restart.

 

to sum up:

Do not be too believe their control of the code, as long as the code is thread function, add a try insurance, I can not escape this level of error in case of some kind, for the software is really stability overrides everything.

 

2: The software can be started only a single instance of knowledge:

Sometimes, we allow only one instance of the software to start, so we usually have such a universal code detection segment:

static class Program
{
        public static System.Threading.Semaphore _mutex;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            _mutex = new System.Threading.Semaphore(1, 1, "adkiller");
            if (_mutex.WaitOne(0, false) == false)
            {
                MessageBox.Show ( "software has been launched over!" "Run prompt");
                return;

            } 

 

Need a little change: this upgrade, you need to become a different directory allows more open, so logical, so I wrote a piece of 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 ( "software has been launched over!" "Run prompt");
                        return;
                    }
                }

            } 

 

 

Here also involves the knowledge of two points:

1: Debugging of problems:

When debugging, there is a default .vshost host, resulting in the name of the software running after commissioning: Autumn ad killer .vshost.exe

I want to test multiple software running in a different directory, so in other directories also run the software, the question arises:

Debugged process "Autumn ad killer .vshost.exe" and run directly "Autumn ad killer .exe", is not on the number.

Solution:

At this time, as long as: project - Right Properties - Debug - Enable VS hosting process to remove the hook on it.

 

2: take it for granted error:

That Process.GetCurrentProcess () get out of the current process objects, and always get a list of processes in the same process objects, so only such object cp == pro comparative judgment.

The actual error:

Process.GetCurrentProcess out with objects, and each object is a pro cycling processes are unequal, so a direct judgment is wrong.

 

Online this phase error code of course a bit more:

At first, I did a search online search and found a lot of the same phase and I write code, of course, the Internet has such a judgment error number = sample code, and everyone should pay attention to the next.

Solution:

After careful we found that for the process, its process ID is the same, so the judge's statement read:

cp.Id!=pro.Id

To determine whether the same process by process ID.

 

Well, in this section, the basic share of these two I remember being a relatively small point of knowledge. 

 

Software upgrade: software reset operation, the system will be upgraded automatically.

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

 

In addition, the 10 Challenge off, it still has not completely broken off, continue to continue to force everyone: developers the basics of the game, a total of 10 off, welcome challenge


Reproduced in: https: //my.oschina.net/secyaher/blog/274046

Guess you like

Origin blog.csdn.net/weixin_34306676/article/details/91966874