.NET应用程序的最佳实践是什么?多个exes或多个表单? [英] What is the best practice for .NET Application? Multiple exes or multiple forms?

查看:69
本文介绍了.NET应用程序的最佳实践是什么?多个exes或多个表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近看了很多,我甚至找不到任何东西来引导我进行正确的练习。

我有一个有几个子应用程序的应用程序。我想知道是否将这些子应用程序作为单独的进程(exe文件)启动,然后有一个控制器负责列出,关闭,通信(例如通过IPC)这些子应用程序是一个好习惯吗?

I've been looking a lot recently and I can not even find anything to lead me to the correct practice.
I have an application that has several "sub applications". I wonder if launch these sub applications as separate processes(exe files) and then have a controller that is responsible for listing, close, communicate (eg via IPC) these sub applications is a good practice?

推荐答案

不应该是多个前任。那些将是不同的过程。流程很好孤立;给出了单独的地址空间(如果一个进程尝试使用相同的指针,则指向不同的物理内存地址,这是硬件支持的隔离,分页内存)。流程主要是为隔离而设计,而不是为了需要IPC这样的瓶颈的协作。







更准确地说,在一些相对罕见的情况下,使用多个exes可能是一个可接受的选择。不情愿地,我自己使用这些技术。例如,运行一些命令行OS实用程序,这个实用程序很难或无法从头开始或通过任何可访问的API编写。但是多种情况技术并不适合作为模块化的常规/主流方法。



(以下是C Pallini的评论。)



[结束编辑]



当然,你可以,并且,在许多情况下,你应该使用多个线程。它们不是孤立的,应该使用线程同步原语进行通信。



现在,单独的表单怎么样?这取决于应用程序。对于大多数应用程序,即使是多种形式也不是最好的选择。大多数最佳应用程序使用一种主要形式,并且在此主要形式中,有一些控件(例如,面板)与单独的表单起着相同的作用。查看Visual Studio的停靠UI,以获取典型示例。更简单的UI基于 TabControl 类(Forms和WPF有不同的类)。



上面,我并不是指模态(弹出)形式。当然,它们是分开的,不计算在内。但是,在一个风格良好的单一形式的应用程序中,即使是这些模态形式的数量也应该受到限制。大多数操作应该是非线性的(我从视频编辑器领域借用了这个术语),这意味着用户可以随时控制应用程序的几乎任何方面,而不是以任何预定义的顺序(如向导) )。模态形式阻止修改其他形式的任何状态,直到模态形式关闭,因此请谨慎使用它们。



-SA
No way should it be "multiple exes". Those would be different processes. Processes are well isolated; there are given separate address spaces (if one process tries to use the same pointer, it points to a different physical memory address, this is the isolation supported by hardware, paged memory). Process are primarily designed for isolation, not for collaboration which would required such a bottleneck as IPC.



More exactly, in some relatively rare cases, using "multiple exes" could be an acceptable option. Reluctantly, I used such techniques myself. For example, to run some command-line OS utility which is hard or impossible to write from scratch or through any accessible API. But "multiple exes" technique is not suitable as a regular/mainstream approach to modularization.

(Credit to the comment by C Pallini below.)

[END EDIT]

Of course, you can, and, in many cases, you should use multiple threads. They are not isolated and should communicate using thread synchronization primitives.

Now, how about separate forms? It depends on the application. For majority of applications, even multiple forms is not the best idea. Majority of best application uses one main form, and, inside this main form, there are controls (say, panels) which play the same role as your separate forms. Look at the docked UI of Visual Studio, for a typical example. Much simpler UI is based on the TabControl class (there are different classes for Forms and for WPF).

Above, I didn't mean modal (pop-up) forms. Of course, they are separate be definition and don't count. But, in a well-styled single-form application, even the number of those modal forms should be limited. Most operations should be "non-linear" (I borrowed this term from the field of video editors), which means that the user can control almost any aspect of the application at any moment, not in any predefined order (as in "wizards"). Modal forms prevent modifying any states on other forms until the modal form is closed, so use them sparingly.

—SA


不,你应该使用多种形式。

很少使用多个exe或dll,它们在功能上是独立的
No, you should go with multiple forms instead.
Multiple exe's or dlls are rarely used which are independent in there functionality


这篇关于.NET应用程序的最佳实践是什么?多个exes或多个表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆