用户登录会话时运行的程序。 [英] Program that runs when a user login to a session.

查看:82
本文介绍了用户登录会话时运行的程序。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想启动一个进程,将一些缓存信息(角色和应用程序详细信息保存在内存中)直到该会话结束,而不是每次访问服务器。我怎么能在Windows (Windows7 / xp,Windows 2000等)?可能会看到单一解决方案

我们可以在每次登录/登录会话中启动Windows服务吗?

谢谢

Boby Jose

解决方案

会话



你需要使用全局变量或静态类。



参考 - c#中的窗体应用程序会话 [ ^ ]。

< blockquote class =FQ>

Quote:

Windows窗体中没有Session变量的概念。你可以做的是:



创建一个静态类,其中包含用户名和密码以及整个应用程序所需的任何其他变量。



在您的情况下,它将类似于:

  public   static   LoginInfo 
{
public static string UserID;
}



现在您只需从代码中的任何位置访问UserID:

 MessageBox .Show(LogInfo.UserID); 



或者在登录后设置值,例如

 LogInfo.UserID = TextBox1.Text; 







缓存



查看以下内容。



1. [MSDN]缓存应用程序块 [ ^ ]。

2. 在WinForms应用程序中使用缓存 [ ^ ]


Hi All,
I want to start a process that keeps some cache info (roles and apps details in memory) till end of that session rather each and every times access server. How can I do in windows (Windows7/xp, windows 2000 etc)? Likely to see a single solution.
Can we start "windows service" in each logon/login session"?
thanks
Boby Jose

解决方案

Session

You need to use Global Variables or Static Classes.

Refer - Session for windows forms application in c#[^].

Quote:

There is no concept of Session variables in windows forms. What you can do is:

Create a Static class that holds the User name and password and any other variables needed across the application .

In your case it would be something like:

public static class LoginInfo
{
    public static string UserID;
}


Now you can access the UserID simply from anywhere in your code:

MessageBox.Show(LogInfo.UserID);


Or set the values after login like

LogInfo.UserID=TextBox1.Text;




Cache

Go through the below ones.

1. [MSDN] The Caching Application Block[^].
2. Using Cache in Your WinForms Applications[^]


这篇关于用户登录会话时运行的程序。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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