当前位置:编程学习 > C#/ASP.NET >>

引用webservice寄存内存,加速调用如何实现?

问题:我想在app1调用过webservice后,app2再调用就像第2次调用一样,耗时很短。因为他们调用同一dll通讯,比如寄存内存或其他方法加速调用?

第1次使用的时间截图(耗时多于1秒,本地执行的速度)

第2次使用的时间截图(耗时差不多在0.01秒左右,本地执行的速度)

app1及app2代码

private void button1_Click(object sender, EventArgs e)
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            int k = com.WebCom.sum((int)numericUpDown1.Value, (int)numericUpDown2.Value);
            sw.Stop();
            double d=sw.ElapsedMilliseconds * 1.0d / 1000;
            label1.Text = string.Format("结果:{0};耗时:{1}秒", k.ToString(), d.ToString());            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string s = @"C:\Users\Chow\Desktop\dllWebservice\WebService1\app1\bin\Debug\app1.exe"; //或者app2.exe
            Process.Start(s);//启动  
        }


公共调用的dll(引用webservice)

namespace com
{
    public class Class1
    {
        public testWeb.Service1 webservice1 = new testWeb.Service1();
    }

    public class WebCom
    {
        public static int sum(int i1,int i2)
        {
            return new Class1().webservice1.sum(i1, i2);
        }
    }
}

webservice服务端

 public class Service1 : System.Web.Services.WebService
    {
        [WebMethod]
        public int sum(int i1, int i2)
        {
            return i1 + i2;
        }
    }
--------------------编程问答-------------------- http://stackoverflow.com/questions/784918/asmx-web-service-slow-first-request --------------------编程问答--------------------
引用 1 楼 caozhy 的回复:
http://stackoverflow.com/questions/784918/asmx-web-service-slow-first-request


看不懂呢。 --------------------编程问答-------------------- 现在问题解决了没?
补充:.NET技术 ,  Web Services
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,