例如,如果将字符串变量的值设置为“Hello World”,只要该变量可访问,它就会保留其值。与 Web 应用程序不同,您无需显式执行任何操作即可保留它。所以正确的问题可能是
为什么我们不需要在 WinForms 应用程序中实现会话管理?
尽管我会被答案的显而易见性所难倒。
[...] why we cannot implement state management in Winforms [...]
This is an incorrect statement. In fact, we implement session management in every Winforms application, and we are so habitual about doing it that we don't even realise we are doing it.
The very nature of a desktop application is that all the state information you need is available in process memory, and it remains available as long as your application is running.
For example, it you set the value of a string variable to "Hello World", it will retain its value as long as that variable is accessible. Unlike web applications, you don't have to do anything explicitly to retain it. So the correct question might be
Why don't we need to implement session management in a WinForms application?
although I would be stumped by the obviousness of answer.
发布评论
评论(2)
这是一个不正确的说法。事实上,我们在每个 Winforms 应用程序中都实现了会话管理,而且我们已经习惯这样做了,甚至没有意识到我们正在这样做。
桌面应用程序的本质是,您需要的所有状态信息都在进程内存中可用,并且只要您的应用程序正在运行,它就保持可用。
例如,如果将字符串变量的值设置为“Hello World”,只要该变量可访问,它就会保留其值。与 Web 应用程序不同,您无需显式执行任何操作即可保留它。所以正确的问题可能是
尽管我会被答案的显而易见性所难倒。
This is an incorrect statement. In fact, we implement session management in every Winforms application, and we are so habitual about doing it that we don't even realise we are doing it.
The very nature of a desktop application is that all the state information you need is available in process memory, and it remains available as long as your application is running.
For example, it you set the value of a string variable to "Hello World", it will retain its value as long as that variable is accessible. Unlike web applications, you don't have to do anything explicitly to retain it. So the correct question might be
although I would be stumped by the obviousness of answer.
我们可以在Winforms中实现状态管理。
假设您需要通过单击第一个窗体上的按钮来访问另一个 Winforms 应用程序中的 Winforms 控件值。您可以通过以下方式访问它们:
button_click
事件中设置第二个表单的类成员的值因此该类及其成员可以用于在Winforms应用程序中实现状态管理。
We can implement state management in Winforms.
Assume you need to access a Winforms control value in another Winforms application by clicking a button on the first form. You can access them by:
button_click
eventSo the class and its members can be used in achieving state management in Winforms application.