如何在WPF中设置和获取会话? [英] how to set and get session in wpf?.

查看:94
本文介绍了如何在WPF中设置和获取会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

如何在WPF中实现会话.请提出一个想法.

Hi Friends,

How to implement the session in wpf. Give an idea pls.

推荐答案

WPF应用程序是有状态的.这意味着它们不需要在持久会话中存储状态.您是否正在尝试创建应用程序范围的数据存储?如果是这样,您可以简单地创建一个静态类并在其中适当地分配值(会话在内部只是一个Dictionary< string,object>).
WPF applications are stateful. That means that they do not need to store state in a persistent session. Are you perhaps trying to create an application wide datastore? If so, you can simply create a static class and assign values in there as appropriate (a session is just a Dictionary<string, object> internally).


[添加到Pete的回答]

许多WPF应用程序通常使用WCF后端,在这种情况下,状态/会话是通过服务进行管理的.因此,如果您有多个具有登录功能的客户端(具有登录功能),则该服务具有识别每个客户端并维护特定于客户端的会话状态的机制.这样做没有绝对标准,但是开发人员可以根据自己的意愿来实现.

也就是说,WCF包含某种内置的会话功能(比您在ASP.NET中拥有的功能简单得多).您可以在这里阅读有关信息:
http://msdn.microsoft.com/en-us/library/ms733040.aspx [ ^ ]
[Adding to Pete''s answer]

Many WPF applications typically use WCF backends, and in this case state/session is managed through the service. So if you have multiple clients (with login capabilities) connecting to the same service, the service has mechanisms to identify each client and to maintain client-specific session state. There is no absolute standard to doing this and it''s up to the developer to implement this however they want to.

That said WCF includes some kind of built-in session fucntionality (far simpler to what you have in ASP.NET). You can read about it here:
http://msdn.microsoft.com/en-us/library/ms733040.aspx[^]


这篇关于如何在WPF中设置和获取会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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