The overall concept and specific application of multithreading

What are multithreaded applications and net?
  1. Application of multithreading

1.1. Basic concepts of multithreading

In this system, not only real-time data acquisition and processing, but also data display and refresh, but also continuous scanning for faults and control commands. Moreover, each serial port is equipped with multiple communication devices. In order to make such a large system run stably, quickly and safely, single thread cannot be realized, so we must adopt Net. When a program runs in a computer, the operating system will assign it a process, and thread is a basic component of the process. A thread is a stream of instructions that runs independently in a program. Within the operating system, a process needs to include at least one thread. Multithreading is to decompose the tasks to be executed into multiple sub tasks, so as to divide the whole work into multiple individual tasks, and execute these tasks in parallel mode, so as to improve the operation efficiency of the system.

Yes Net framework class library, thread class is used to create and control threads, which is included in sys tem In threading namespace, to use multithreading, you must first reference this namespace Using system Threading.

1.2. Main thread

The main thread is started by the main () method. The main thread of the application mainly completes the following work; System initialization, auxiliary thread creation and management, data refresh display, form switching, alarm scanning, data recording, man-machine interface event response, report management and printing, etc.

1.3. Data acquisition thread

After the main thread is created, it will not collect data until the main thread is started. The data acquisition thread mainly completes three aspects: firstly, it receives the data, and then analyzes the received message. Finally, the parsed data is stored. If there is a fault alarm in this process, it is necessary to respond immediately. After all the work is completed, the first process starts to be executed and continues to cycle. These three processes are encapsulated in the form of classes by net component technology, and the thread of data acquisition module can flexibly call the function functions of each class.

1.4. Control command thread

When users send fixed value setting, instrument timing, reset and other commands to the field equipment through the upper computer interface on the local monitoring computer, in order to send the command to the equipment as soon as possible, the main thread specially creates a control command processing thread for processing. The main work of this thread module is to obtain the control command from the response event of the upper computer interface, and then organize the message to send the command according to the controlled or operated object. The response speed of control command in this way is faster

1.5 relationship between threads

After the upper computer monitoring software program is started, the main thread first initializes the system, and then creates a data acquisition thread for cyclic data acquisition.

  1. Net and related technologies

2.1. Net technology

. net is used by Microsoft to implement XML Web services, SOA and agility technologies Net application is compiled into mil (mierosoft intermediate language) and run through CLR virtual machine instead of local machine code, which lays a foundation for cross platform development in the future Net provides a unified language development environment. It supports a variety of development languages, including c#, VB, C + +, etc. these languages are compiled into intermediate code that can run on CLR. In addition Net framework development platform also allows users to create a variety of applications: XML Web service, web form, Win32 GUI application, Win32 Cui (console U1) application Windows services (controlled by the service control manager), utilities, and independent component modules. Net is shown in the figure.

Net structure
Net structure

2.2 net framework technology

The. Net framework is Net platform innovation Net framework aims to make it easier for developers to establish web applications and web services. Its key feature is to provide a consistent object-oriented programming environment and start to realize the environment of multilingual component development and execution. meanwhile.. Net framework is also an internal windows component that supports the generation and running of Next-Generation Applications and web services. Based on this, web services can be developed easily and quickly

The. Net framework has two main components: the common language runtime (CLR) and Net framework class library. CLR is Net framework, which provides core services such as memory management, thread management and remote processing, enforces strict type safety, and provides security and reliability Net framework is another major component of the class library, which is a comprehensive object-oriented reusable type collection, which provides developers to develop various types of applications. use. Net framework class library can develop a variety of applications, including traditional command-line or graphical user interface (gu1) applications, or based on ASP Net (such as web forms and xmil. Web Service) Net framework class libraries mainly include data access, security and file 1 / 0 XMI, operation, messaging, class reflection, XML Web Service,ASP. Net and MI crosoft windows services provide support for various tasks including.

Above the service framework are two types of application templates, one is the traditional windows application template, the other is based on ASP Net. Among them, ASP and net provide a web application model in the form of a group of controls and architecture. It is constructed from the class library provided by the. Net framework. Through it, the implementation process of web application can be simplified.

2.3 c# language

. net supports c#, VB NET,VC. Net and other development languages, which provides a multilingual development environment In this project, c# language is selected for development. C # is evolved from C and C + + languages and is Microsoft Net is the only core language for Net framework design language, you can use Net framework code base provides each function, which is more convenient to develop. Moreover, it is a completely object-oriented and component-oriented language, which simplifies the process of system development, improves the development efficiency, and is conducive to the future expansion and reuse of the program.

2.4 ASP. Net technology

Windows form is the technology of writing Windows applications, and using ASP and net, we can create web applications that can be displayed on any browser. Using ASP and net to create a web application on the client system only requires a simple web browser. The client system does not need to be installed. Net and ASP are required on the server Net runtime, IIS (Internet information services) is installed on the web server of this project Net framework will automatically configure ASP. Net for the server Net runtime.

ASP. Net runtime works as shown in Figure . The client requests default from the server aspx。 All ASP Net web pages usually have extensions Aspx, because this file extension is registered by IIS ASP. Net web development server can recognize it. So ASP Net runtime and ASP Net worker process will begin to work. The first request for the file default, ASPX will start ASP Net analyzer. The compiler combines the file with a Aspx files and related c# files are compiled together to create an assembly. The JIT compiler of the. Net runtime then compiles the assembly into native code. The assembly contains a page class that calls HTMi The code is returned to the client. Then delete the page object. However, the assembly is preserved so that it does not need to be compiled again when requested again

ASP. Net application principle
ASP. Net application principle

As can be seen from figure , the process of web page request issued by the browser is as follows:

Send request: the browser simply sends the web address to the web server

Send source code: when the web server receives the request from the browser, it will include ASP Net program code, send to NET Framework.

Yes Net framework will directly execute the source code after receiving the program code required to be executed, and finally generate and convert the standard HTMi The file is returned to the web server. The process of returning results is as follows:

Returns standard HTML File: in Net framework, the result will be standard HTML without ASP and net program code Documents.

Return to HTMi File: after the web server receives the result returned by the net framework, its job is to send the standard HTML file back to the browser.

ASP. Net is a classification of logical relations, including presentation layer (USL) and business logic layer

(BL) and data access layer (DAL). This project adopts such a three-tier structure to put the business rules, data access, legitimacy verification and other work into the business logic layer of the middle layer for processing. The browser side does not directly interact with the database, but interacts with the database through the middle layer, making the structure clearer and the division of labor clearer, so as to facilitate the maintenance of the system.