Victor.Stone
dot net 备忘录
posts - 21,  comments - 25,  trackbacks - 0
下面是今天做的一个小试验代码:

        private void FrmMain_Load(object sender, EventArgs e)
        
{
            
this.pictureBox1.Visible = false;

            BinaryServerFormatterSinkProvider serverProvider 
= new BinaryServerFormatterSinkProvider();
            BinaryClientFormatterSinkProvider clientProvider 
= new BinaryClientFormatterSinkProvider();
            serverProvider.TypeFilterLevel 
= TypeFilterLevel.Full;

            IDictionary props 
= new Hashtable();
            
//props["bindTo"] = "121.12.157.244";//"113.105.185.151"; 
            props["port"= 0;
            HttpChannel channel 
= new HttpChannel(props, clientProvider, serverProvider);
            ChannelServices.RegisterChannel(channel, 
false);
            
            
this.user = (IUser)Activator.GetObject(
                
typeof(IUser),
                
"http://localhost:9090/User.soap"); 
        }


        
public delegate string MyDelegate(int a);
        
private MyDelegate md;
         
        
public void CallBack1(IAsyncResult Iar)
        
{
            
if (Iar.IsCompleted)
            
{
                
this.Text = md.EndInvoke(Iar);
                
this.pictureBox1.Visible = false;
            }

        }


        
private void button1_Click(object sender, EventArgs e)
        
{
            
this.Text = "";
            md 
= new MyDelegate(this.user.GetValue);
            AsyncCallback ac 
= new AsyncCallback(CallBack1);
            IAsyncResult Iar 
= md.BeginInvoke(345, ac, null);
            
this.pictureBox1.Visible = true;            
        }

posted on 2010-12-20 22:19 Victor.Stone 阅读(340) 评论(0)  编辑 收藏 引用 所属分类: 分布式应用
只有注册用户登录后才能发表评论。

<2010年12月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(2)

随笔分类(17)

文章分类

搜索

  •  

积分与排名

  • 积分 - 23821
  • 排名 - 192

最新随笔

阅读排行榜