webservice异步调用

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

None.gif [STAThread]
None.gif        
static   void  Main() 
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            Application.Run(
new Form1());
ExpandedBlockEnd.gif        }

None.gif
None.gif        
private   void  Form1_Load( object  sender, System.EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif        
InBlock.gif
InBlock.gif        
ExpandedBlockEnd.gif        }

None.gif        
public   static   void  WebCallback(IAsyncResult ar)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
InBlock.gif            hlk.Service1 hlks
=(hlk.Service1)ar.AsyncState;
InBlock.gif            
InBlock.gif            MessageBox.Show(
"okok");
InBlock.gif            bytePic
=hlks.EndGetImage(ar);
InBlock.gif            
InBlock.gif                
ExpandedBlockEnd.gif        }

None.gif
None.gif        
None.gif
None.gif
None.gif        
private   void  button1_Click( object  sender, System.EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            webS异步调用.hlk.Service1 webS
=new webS异步调用.hlk.Service1();
InBlock.gif            path
=this.textBox1.Text;
InBlock.gif
InBlock.gif            AsyncCallback cb
=new AsyncCallback(Form1.WebCallback);
InBlock.gif                    
InBlock.gif            IAsyncResult ar 
= webS.BeginGetImage(path, nullnull);
InBlock.gif
InBlock.gif            
// Wait for the asynchronous operation to complete.
InBlock.gif
            ar.AsyncWaitHandle.WaitOne();
InBlock.gif
InBlock.gif            
// Get the completed results.
InBlock.gif
            byte[] results;     
InBlock.gif            results 
= webS.EndGetImage(ar);
InBlock.gif          
InBlock.gif            
//Output the results.
InBlock.gif
            System.IO.MemoryStream ms=new System.IO.MemoryStream(results);
InBlock.gif            
this.pictureBox1.Image=Image.FromStream(ms);
InBlock.gif        
ExpandedBlockEnd.gif        }

转载于:https://www.cnblogs.com/NewLand/archive/2005/12/02/289136.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值