| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | #include "stdio.h" |
| 6 | |
| 7 | #pragma warning(push) |
| 8 | #pragma warning(disable:4265 4577) |
| 9 | #include <thread> |
| 10 | #pragma warning(pop) |
| 11 | |
| 12 | // Work around typedef redefinition: platformdefines.h defines error_t |
| 13 | // as unsigned while it's defined as int in errno.h. |
| 14 | #define error_t error_t_ignore |
| 15 | #include <platformdefines.h> |
| 16 | #undef error_t |
| 17 | |
| 18 | typedef void (*PFNACTION1)(); |
| 19 | |
| 20 | extern "C" DLL_EXPORT void InvokeCallback(PFNACTION1 callback) |
| 21 | { |
| 22 | callback(); |
| 23 | } |
| 24 | |
| 25 | extern "C" DLL_EXPORT void InvokeCallbackOnNewThread(PFNACTION1 callback) |
| 26 | { |
| 27 | std::thread t1(InvokeCallback, callback); |
| 28 | t1.join(); |
| 29 | } |