已经建立webservice:http:// webs异步调用.servervice1.asmx

[STAThread]
        
static void Main() 
        
{
            Application.Run(
new Form1());
        }


        
private void Form1_Load(object sender, System.EventArgs e)
        
{
        

        
        }

        
public static void WebCallback(IAsyncResult ar)
        
{
            
            hlk.Service1 hlks
=(hlk.Service1)ar.AsyncState;
            
            MessageBox.Show(
"okok");
            bytePic
=hlks.EndGetImage(ar);
            
                
        }


        


        
private void button1_Click(object sender, System.EventArgs e)
        
{
            webS异步调用.hlk.Service1 webS
=new webS异步调用.hlk.Service1();
            path
=this.textBox1.Text;

            AsyncCallback cb
=new AsyncCallback(Form1.WebCallback);
                    
            IAsyncResult ar 
= webS.BeginGetImage(path, nullnull);

            
// Wait for the asynchronous operation to complete.
            ar.AsyncWaitHandle.WaitOne();

            
// Get the completed results.
            byte[] results;     
            results 
= webS.EndGetImage(ar);
          
            
//Output the results.
            System.IO.MemoryStream ms=new System.IO.MemoryStream(results);
            
this.pictureBox1.Image=Image.FromStream(ms);
        
        }
posted on 2005-12-02 11:54  kuning的程序博客  阅读(733)  评论(0编辑  收藏  举报