WCF中对于一个Service用for循环调用,为什么后面的会比第一次快很多呢(在第一次结束时已经关闭了client)?这个和信道栈有关系么?
(注:马上再次执行也是第一次比较慢)
代码如下:
public static void InvokeService()
{
Client client = null;
try
{
client = new Client();
Console.WriteLine("Call Service began, the time is {0}", DateTime.Now.TimeOfDay.ToString());
client.CallService();
Console.WriteLine("Call Service Successed, the time is {0};", DateTime.Now.TimeOfDay.ToString());
client.Close();
client = null;
Console.ReadKey();
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
client.Abort();
Console.ReadKey();
}
}
static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
InvokeService();
}
}