我写了6个过程,在这6个过程中,分别去链接6个不同的webservices取数,然后我在page_load 里面这样写:protected void Page_Load(object sender, EventArgs e)
{过程1();
过程2();
过程3();
过程4();
过程5();
过程6();}那么这6个过程是依次执行还是同时执行呢?在执行第一个过程中去链接webservices的时候,另外的过程是等着还是也在链接?我有两个问题,第一个,我如何让这个网页先显示出来,然后再去执行这些函数呢?
第二个,我如何让这六个过程分别执行呢?

解决方案 »

  1.   

    这个是依次执行的!你可以打断点调试!protected   void   Page_Load(object   sender,   EventArgs   e) 

    Response.Write("过程1");
    过程1(); 
    Response.Write("过程2");
    过程2(); 
    Response.Write("过程3");
    过程3(); 
    Response.Write("过程4");
    过程4(); 
    Response.Write("过程5");
    过程5();
    Response.Write("过程6"); 
    过程6(); } 
      

  2.   

    就你现在是顺序执行的,在执行第一个过程中去链接webservices的时候,另外的过程是等着;
    所以如果第一个过程对后面没有影响的话,可以给第一个过程单独一个线程,就可以了;这样的话你的两个问题基本都可以解决;
      

  3.   

    yes~,哈哈,谢谢楼上,现在问题是如何让他们单独一个线程呢?这个我不会写,网上找了很多例子都很复杂,我看不大懂,谢谢!
      

  4.   

    写在一堆 我就没办法了!
    单个调试的方法好象只有一个设置断点,依次调试!
    使用try,catch
    把每一个的数据集在及时窗口里面打出来!
      

  5.   

          thread dummythread = new thread( new threadstart(somefunction1) ; 
        dummythread.isbackground=true; 
        dummythread.name = "first thread"; 
        dummythread.start( );     thread dummyprioritythread = new thread( new threadstart(somefunction2) ); 
        dummyprioritythread.isbackground=true; 
        dummyprioritythread.name = "second thread"; 
        dummyprioritythread.start( ); 
    ...........................
    .........................
      
    有6个就写6个
      

  6.   

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Threading;/// <summary>
    /// TestThead 的摘要说明
    /// </summary>
    public class TestThead
    {
    public TestThead()
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
    }    public static void Thread_GetSumPrice()
        {
            DepWs02.Service sd = new DepWs02.Service();        string StrR;        try
            {
                StrR = sd.ReturnString(strConnection, "select  cast(sum((case when 行号=1 then 滞纳金 else 0 end)+实纳金额 )as numeric(18,0))  as Result " +
                " from 完税证信息新 where 征收机关ID='02' and 完税证状态='缴销' and  填发日期 between '2007-01-01' and getdate()");
            }
            catch
            {
                StrR  = "无链接";
            }
            finally
            {
                sd.Dispose();
            }       
        }    public static void Main()
        {
            ThreadStart thr_start_func = new ThreadStart(Thread_GetSumPrice);
            Thread fThread = new Thread(thr_start_func);
            fThread.Name = "first_thread";
            fThread.Start(); 
        }}以上是我写的一个线程的代码,我写在一个类里面,Thread_GetSumPrice是主要的代码,
    Main是调用线程的代码,我想知道,我在外面某个页面上,如何调用这个线程让它开始
    我如何能得到StrR的值?或者是不是需要别的方法来得到线程的返回值?
    我怎么能知道这个线程死掉了,或者是执行完成了呢?