我想强调我的网站有多个访问。为此,我创建了一个基于Windows的应用程序,该应用程序调用了1000次该网站。 不幸的是它只适用于2个电话。这是代码:基于Windows的应用程序来测试我的ASP.NET应用程序
static void myMethod(int i)
{
int j = 0;
try
{
string url = "";
WebRequest wr = null;
HttpWebResponse response = null;
url = String.Format("http://www.google.com");
wr = WebRequest.Create(url);
//wr.Timeout = 1000;
response = (HttpWebResponse)wr.GetResponse();
MessageBox.Show("end");
}
catch (Exception ex)
{
MessageBox.Show(j.ToString() + " " + ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 1000; i++)
{
ThreadStart starter = delegate { myMethod(i); };
Thread thread = new Thread(starter);
thread.Start();
}
}
两次尝试后会发生什么?是否抛出异常? – granaker 2012-01-13 09:48:03
你知道,如果这个工作,你会产生1000个消息框?另外 - 我不知道你是否被允许从后台线程打开一个消息框。任何人都可以确认吗? – 2012-01-13 09:49:27
为什么要尝试并重塑已有的功能。 http://support.microsoft.com/kb/231282 http://loadimpact.com/ – Lloyd 2012-01-13 09:58:49