c#的一些书写技巧

从非创建线程访问线程资源

Invoke(new Action<int>((o)=>

textBox1.Text = (Convert.ToInt32(textBox1.Text) + o).ToString();
}), new object[] { msg });

 

wcf channel资料统一管理

string Hello(string words){

var funcHelloWS=new Func<ISPWCFService,string>((iproxy,iwords)=>{

iproxy.HelloWS(iwords);

});

 

}

-------------------------ClientWrap----------------------

public string  HelloWSClient(Func<T,string,string> funHelloWS,string words)

{

string r="";

try{

using(ChannelFactory<T> cfx=GetChannelFactory<T>())

{

T proxy=cfx.CreateChannel();

r=funHelloWS(proxy,words);

}

}

catch(Exception er){

-----------

}

}

posted @ 2019-09-06 13:46  jeffery1010  Views(205)  Comments(0Edit  收藏  举报