社区
C#
帖子详情
在windows应用程序里面如何使用cache?
sheng9hhd
2006-02-25 10:43:21
不是web,命名空间是哪个?
using System....????????
怎么用的?
...全文
161
2
打赏
收藏
在windows应用程序里面如何使用cache?
不是web,命名空间是哪个? using System....???????? 怎么用的?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
孟子E章
2006-02-25
打赏
举报
回复
http://www.codeproject.com/csharp/cacheinwinformapps.asp
孟子E章
2006-02-25
打赏
举报
回复
using System.Web;
using System.Web.Caching;
Using Cache in Your WinForms Applications
<PRE lang=cs>using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Web.Caching;
using System.Data;
namespace CacheSample
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtValueToPutInCache;
private System.Windows.Forms.TextBox txtValueInCache;
private System.Windows.Forms.Button btnPutInCache;
private System.Windows.Forms.Button btnGetFromButton;
private const string CACHE_KEY = "APPCACHEKEY";
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtValueToPutInCache = new System.Windows.Forms.TextBox();
this.txtValueInCache = new System.Windows.Forms.TextBox();
this.btnPutInCache = new System.Windows.Forms.Button();
this.btnGetFromButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(8, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(113, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Value to put in cache:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(8, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(95, 16);
this.label2.TabIndex = 1;
this.label2.Text = "Value from cache:";
//
// txtValueToPutInCache
//
this.txtValueToPutInCache.Location = new System.Drawing.Point(128, 16);
this.txtValueToPutInCache.Name = "txtValueToPutInCache";
this.txtValueToPutInCache.Size = new System.Drawing.Size(200, 20);
this.txtValueToPutInCache.TabIndex = 2;
this.txtValueToPutInCache.Text = "";
//
// txtValueInCache
//
this.txtValueInCache.Location = new System.Drawing.Point(128, 40);
this.txtValueInCache.Name = "txtValueInCache";
this.txtValueInCache.ReadOnly = true;
this.txtValueInCache.Size = new System.Drawing.Size(200, 20);
this.txtValueInCache.TabIndex = 3;
this.txtValueInCache.Text = "";
//
// btnPutInCache
//
this.btnPutInCache.Location = new System.Drawing.Point(352, 16);
this.btnPutInCache.Name = "btnPutInCache";
this.btnPutInCache.Size = new System.Drawing.Size(104, 23);
this.btnPutInCache.TabIndex = 4;
this.btnPutInCache.Text = "Put in Cache";
this.btnPutInCache.Click +=
new System.EventHandler(this.btnPutInCache_Click);
//
// btnGetFromButton
//
this.btnGetFromButton.Location = new System.Drawing.Point(352, 40);
this.btnGetFromButton.Name = "btnGetFromButton";
this.btnGetFromButton.Size = new System.Drawing.Size(104, 23);
this.btnGetFromButton.TabIndex = 5;
this.btnGetFromButton.Text = "Get from Cache";
this.btnGetFromButton.Click +=
new System.EventHandler(this.btnGetFromButton_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(488, 133);
this.Controls.Add(this.btnGetFromButton);
this.Controls.Add(this.btnPutInCache);
this.Controls.Add(this.txtValueInCache);
this.Controls.Add(this.txtValueToPutInCache);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
private void btnPutInCache_Click(object sender, System.EventArgs e)
{
AppMain.Cache.Insert(
CACHE_KEY,
txtValueToPutInCache.Text,
null,
Cache.NoAbsoluteExpiration,
TimeSpan.FromSeconds( 60 ) );
}
private void btnGetFromButton_Click(object sender, System.EventArgs e)
{
string value;
value = AppMain.Cache[ CACHE_KEY ] as string;
if( null == value )
{
value = "[No value in the cache.]";
}
txtValueInCache.Text = value;
}
}
}</PRE>
在ASP.NET中
使用
Session、
Cache
与Application时注意IIS
应用程序
池的空闲超时
在.NET的ASP.NET、ASP.NET MVC与WebService等应用中,常常
使用
Session、
Cache
或Application保存服务器端共享数据,如果没有
使用
SqlServer保存这些缓冲区数据,那么就存在超时与过期问题:超时后Session和
Cache
就过期...
无法安装或运行此
应用程序
。该
应用程序
要求首先在"全局程序集缓存(GAC)"中安装程序集
问题:无法安装或运行此
应用程序
。该
应用程序
要求首先在”全局程序集缓存(GAC)”中安装程序集 解决(可能):双击第1步,第4步设置为包括
jdk下载过程中显示“以下
应用程序
正在
使用
需要由此安装程序更新的文件”
下载JDK出现如下图所示问题: 我的解决方法: 1.以管理员身份打开命令提示...4,在我以为问题解决了的时候,又弹出一个相同的问题 5.按照上述方法我又把ID为11588的这个进程给关了 6.至此jdk安装成功 ...
【Web】Web
应用程序
的工作原理
Web
应用程序
是一种通过网络(通常是互联网)...2.Web
应用程序
能够根据用户的请求和服务器端的处理,在客户端动态生成内容。相比之下,普通网页是静态的,其内容在服务器上预先生成,并以相同的形式发送给所有用户。3.
缓存
Cache
详解
一、什么是缓存
Cache
? 为什么人们要
使用
它?一个
使用
缓存
Cache
的站点会监听客户端向服务器端发出的请求,并保存服务器端的回应——比如HTML页面、图片等文件。接着,如果有另外一个
使用
相同URL发送请求,他能够
使用
...
C#
110,536
社区成员
642,578
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章