Public object invoke (delegate method)
That is to say, it accepts a delegate. Therefore, any instance derived from delegate is acceptable. We know that threadstart and methodinvoker are derived from delegate, so when the compiler converts this anonymous function, it does not know whether to convert this anonymous function to threadstart or methodinvoker, so an error is reported. (Representing a delegate function, there are parameterizedthreadstart, waitcallback, asynccallback, etc., but they all have parameters .)
The above description is to copy others; detailed from http://hi.baidu.com/%C2%E4%CB% AE %C9%F1/blog/item/548f3edf8fe7eff577c638aa.html
WPF
Private void btn2_click (Object sender, routedeventargs E)
{
Thread _ t = new thread (New threadstart (delegate (){
This. Dispatcher. Invoke (new action () =>{ execution content}), null );
}));
_ T. Start ();
}
Winfrom
Private void btn2_click (Object sender, routedeventargs E)
{
Thread _ t = new thread (New threadstart (delegate (){
This. Invoke (New methodinvoker () =>{ Execution Code }));
}));
_ T. Start ();
}