c# - Inlining some events in BackgroundWorker? -
im not sure, called inlining when in 1 line?
i code have backgroundworker. doworker enforce sleep of on sec , runworkercompleted noe bit of code. possible instead of defining function in 1 line like
.dowork += ((sender, arg) => { ... });
and
.runworkercompleted += ((sender, arg...
what right syntax this, , called? nice keep things simple when have simple task @ hand :-)
you confusing inlining
lambda expressions
. inlining replacing calling of method body, example:
int timestwo(int x) { return x * 2; } //before inlining: int = timestwo(6) + timestwo(7); //after inlining: int = 6 * 2 + 7 * 2;
this compiler optimization technique avoid method call overhead.
for backgroundworker
example correct syntax be:
backgroundworker worker = new backgroundworker(); worker.dowork += (sender, e) => runmymethod(); //or worker.dowork += (sender, e) => { runmymethod(); }
for more information see msdn.
Comments
Post a Comment