multithreading - C# Control.Invoke a method group -
i using threads run long operations in program's ui doesn't lock up. however, in tasks need update controls, impossible not thread created on. suggested use control.begininvoke(delegate) execute method want.
however, have declare delegate type , can call them.
so, goes this: if want execute method void update(), have go:
delegate void callbackvoid(); void update() {...} ...(in task code)... this.begininvoke(new callbackvoid(update));
this rather tiresome every single method out there. can't somehow naturally, like:
void update() {...} this.begininvoke(update);
updated: works wpf!!!
you can use short syntax anonymous methods, without declaring methods
dispatcher.begininvoke(dispatcherpriority.background, new methodinvoker(() => { //your update code }));
Comments
Post a Comment