开发者

Is there a concept of session management in Winforms applications? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
开发者_开发技巧

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 8 months ago.

Improve this question

Today I was asked why we cannot implement state management in Winforms applications like we do in web applications, and I did not know the answer.

Can someone explain why we cannot, or if we can, explain how it works at a high level?


[...] 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.


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:

  1. declaring public class members and auto implemented properties in the second form.
  2. Set the values of the second form's class members in the first form's button_click event
  3. After step 2, run the code you want to run on button click.

So the class and its members can be used in achieving state management in Winforms application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜