multithreading - C#, invoke anonymous method (Action<>) from background thread -
this should simple!
i want create anonymous action<> delegate perform gui update, call several other anonymous delegates (which run on separate threads).
void test() { action<string> invokedisplay = new action<string>(delegate(string element) { //do variety of things gui depending on element parameter }); methodinvoker oplong1 = new methodinvoker(delegate() { // long task this.invoke(invokedisplay("long1")); }); methodinvoker oplong2 = new methodinvoker(delegate() { // long task this.invoke(invokedisplay("long2")); }); new thread(new threadstart(oplong1)).start(); new thread(new threadstart(oplong2)).start(); } so whats correct syntax line?
this.invoke(invokedisplay("long1"));
the syntax be:
invoke(action, "long1"); the delegate first parameter, , argument(s) want pass follow.
Comments
Post a Comment