These both seem to do the same thing.. I'm wondering which one I should use, you would prefer to read, is more efficient, their differences, et cetera..
Lambda #1
synchronizationContext.Post(m => log.AppendText(message), null);
Lambda #2
synchronizationContext.Post(m => log.AppendText(m), message);
My only concern is that with the second one, even though it may look more read-able, isn't their boxing and unbo开发者_开发技巧xing because of the Post method takes an object and message is a string?
Thanks.
Strings are stored in the managed heap, so they don't need to be boxed/unboxed.
Because you don't have do any extra casting (from object to string), I would go with this one:
synchronizationContext.Post(m => log.AppendText(message), null);
精彩评论