Example of Simulating concurrent requests
来源:互联网 发布:java中圆周率怎么表示 编辑:程序博客网 时间:2024/04/30 01:02
protected slaresearch.WebService1SoapClient client; protected monitor.monitorSoapClient monitor; protected void Page_Load(object sender, EventArgs e) { client = new slaresearch.WebService1SoapClient(); monitor = new monitor.monitorSoapClient(); if (Session["txt1"] == null) { Session.Add("txt1", ""); Session.Add("txt2", ""); } else { this.txt1 = (String)Session["txt1"]; this.txt1 = (String)Session["txt2"]; } } private void run1() { DateTime start = monitor.getHostDatetime(); String fabo40 = client.fabonacci(40).ToString(); DateTime end = monitor.getHostDatetime(); TimeSpan duration = end.Subtract(start); txt1 = "fabonacci at 40 is " + fabo40 + "<br/>Start:" + start.ToString() + "<br/>End:" + end.ToString() + "<br/>Duration:" + duration.TotalSeconds.ToString() + "s"; Session["txt1"] = txt1; } private void run2() { DateTime start = monitor.getHostDatetime(); String fabo40 = client.fabonacci(40).ToString(); DateTime end = monitor.getHostDatetime(); TimeSpan duration = end.Subtract(start); txt2 = "fabonacci at 40 is " + fabo40 + "<br/>Start:" + start.ToString() + "<br/>End:" + end.ToString() + "<br/>Duration:" + duration.TotalSeconds.ToString() + "s"; Session["txt2"] = txt2; } private String txt1, txt2; protected void Button1_Click(object sender, EventArgs e) { Thread t = new Thread(new ThreadStart(this.run1)); t.Start(); } protected void Button2_Click(object sender, EventArgs e) { Thread t = new Thread(new ThreadStart(this.run2)); t.Start(); } protected void Button3_Click(object sender, EventArgs e) { Button1_Click(sender, e); Button2_Click(sender, e); } protected void Button4_Click(object sender, EventArgs e) { Label1.Text = (String)Session["txt1"]; Label2.Text = (String)Session["txt2"]; }
NOTICE:
IF YOU WANT TO CONCURRENTLY START MORE THAN 1 THREAD, YOU HAVE TO CREATE EVERYTHING IN YOUR PROCESS.
FOR EXAMPLE:
private void runall() { monitor.monitorSoapClient m = new monitor.monitorSoapClient(); slaresearch.WebService1SoapClient nc = new slaresearch.WebService1SoapClient(); DateTime start = m.getHostDatetime(); String fabo40 = nc.fabonacci(40).ToString(); DateTime end = m.getHostDatetime(); TimeSpan duration = end.Subtract(start); String tmp = "fabonacci at 40 is " + fabo40 + "<br/>Start:" + start.ToString() + "<br/>End:" + end.ToString() + "<br/>Duration:" + duration.TotalSeconds.ToString() + "s<br/>"; Session["all"] = Session["all"] + tmp; }
- Example of Simulating concurrent requests
- Concurrent Requests - Parameters
- Diagnostic Script for Concurrent Requests
- Diagnostic Script for Concurrent Requests .
- Using Concurrent Requests for running sqlplus scripts
- Number of concurrent tasks
- Example of email Phishing
- A example of Log4c
- Basic Example Of RTimer
- Example of Seriazable List
- A example of pointer
- Another example of Expect
- example of creating table
- example of QGridLayout
- example of while [ ]
- Basic Example Of RTimer
- example of QGridLayout
- Example of Makefile
- [siggraph2011]Secrets of CryENGINE 3 Graphics Technology
- Ubuntu vim配置文件及系统安装
- 利用securecrt在linux与windows之间传输文件
- 世界500百强企业中国的CEO对我们的忠告!-----转载
- 多媒体应用: 图形、音频、视频
- Example of Simulating concurrent requests
- Android 2.3 和 2.2 的gc0308 的摄像头
- 00032.Oracle按向导执行数据导入
- 存储过程实例(统计某用户下所有的表的记录数)
- 什么是簇:什么是卷
- 00033.Oracle查询、更新临时表空间
- 老子的软件之道 - 道篇 2 软件架构 – 难中求易
- java interview
- 计算机中的 卷簇文件系统 相关