Multithreading in a dll
<p>I wanted to make two functions running in the background at the same time inside dll so I did <code>CreateThread</code> in dllmain but it doesn't work. Any tips or help?</p>

<pre><code>#include &lt;Windows.h&gt;
#include "main.h"
#include &lt;iostream&gt;

void main()
{
AllocConsole();
freopen("CONOUT$", "w", stdout);
std::cout &lt;&lt; "Press enter?";
while (true) {
    if (GetAsyncKeyState(0x0D))
        Trainer(); Sleep(50);
}
}

BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD Reason, LPVOID Reserved) {
   switch (Reason) {

case DLL_PROCESS_ATTACH:
    MessageBox(0, "DllInject", "Injected", 0);
    CreateThread(0, 0, (LPTHREAD_START_ROUTINE)main, NULL, 0, NULL);
    break;

case DLL_PROCESS_DETACH:
    break;

}
return TRUE;
}
</code></pre>

<p>function example </p>

<pre><code>void artemis()
{
    while (true)
    {
        Sleep(300);
        ammoArtemis = 1;
    }
}
</code></pre>