Current location - Loan Platform Complete Network - Big data management - What is the difference between winform and WPF?
What is the difference between winform and WPF?

WPF develops the Windows presentation layer to use declarative language for development, and integrates a large number of animations and special effects, so that rich client applications that are extremely difficult to achieve in Win32 can be easily implemented in WPF, while using Vector graphics replace bitmaps, routed events (RoutedEvent) are introduced to monitor the element tree at multiple levels, and control trees are dynamically changed through dependency properties (DependencyProperty). When developing WinForm programs, once multi-threaded operations are involved, it is generally impossible for us not to have seen the exception InvalidOperationException. In most cases, this exception occurs due to illegal operations caused by the worker thread (sub-thread) modifying the properties of the main thread control (or object). Of course, this approach does not fail every time, which mainly depends on the operation the sub-thread wants to perform. The object is not thread safe.

The WinForm control provides the InvokeRequired property to determine whether the current thread is the thread that created this control. Once the control is created, InvokeRequired will be efficient and safe. However, if the target control has not been created yet (at this time, although the C# object already exists, its underlying window handle is still null), then InvokeRequired may take a long time. (It will traverse the entire control tree from bottom to top until it finds a parent control that can host this control and has been instantiated and created. This approach ensures that the child control will be created on the same thread as the parent control. Found Once the parent control is appropriate, the framework can perform the same check, comparing the ID of the current thread with the ID of the thread that created the parent control. If the framework cannot find any parent form that has been created, then it needs to find some other type of form. If no available window is found in the hierarchy, the framework will start looking for a parking window. Parking windows allow you to avoid strange behavior of some Win32 APIs. In short, some modifications to the form (such as changing certain styles) require the form to be destroyed and re-created. The temporary form is used to temporarily save the controls in the parent form while it is destroyed and re-created. During this time, the UI thread only runs in the temporary form.

Typically, a WPF application starts with two threads: one to handle rendering and one to manage the UI. The rendering thread effectively runs hidden in the background, while the UI thread receives input, handles events, draws the screen, and runs application code.

WPF is the abbreviation of Windows Presentation Foundation. Its original code name was "Avalon". Because the pinyin of "I admire" has the same combination, some people in China jokingly called it "I admire". WPF is Microsoft's new generation graphics system. It runs under the .NET Framework 3.0 architecture and provides a unified description and operation method for user interfaces, 2D/3D graphics, documents and media. WPF based on DirectX 9/10 technology not only brings an unprecedented 3D interface, but its graphics vector rendering engine also greatly improves the traditional 2D interface. For example, the translucent effect forms in Vista all benefit from WPF. With the help of WPF, programmers can no longer develop a cool interface comparable to Mac programs. WPF has taken a huge step forward compared to the development of Windows clients. It provides a super-rich .NET UI framework, integrated vector graphics, rich flowing text support, 3D visual effects and extremely powerful control model framework.