Use wrap to give correct name to mainthread wrapped func. Fixes #2027.

Fixes #2027.