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

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -