Questions tagged [beginthread]

30 questions
0
votes
1 answer

Starting class functions as threads loosing reference

i am working on a windows program, which does the hard work in threads and the GUI stays in the main loop (in this case i use ImGui OpenGL3) but with implementing more functions, the parameters are getting out of scope when starting a…
alfetta
  • 103
  • 2
  • 9
0
votes
1 answer

Threads not running, why?

I wrote a simple test application to prove that the threads work: // Test.cpp : Defines the entry point for the console application. // #include "stdafx.h" class clsTest { private: uintptr_t muintHandle; static…
SPlatten
  • 5,334
  • 11
  • 57
  • 128
0
votes
1 answer

Suspected memory leak with _beginthread

So, i have some issues with i suspect a memory leak, in order to test i wrote this small code. By commenting the following line: printf("Calc index: %d\n", ArrLength); the code runs well. But when i uncomment it, the program crashed after a couple…
0
votes
3 answers

Error with free function after malloc

The code below results in a crash of C++ on the line: free(arg). I am trying to prevent a memory leak from happening but i can't manage to free the data i stored in heap memory. Can someone help me with this problem? Note that free(args) works…
0
votes
1 answer

ShellExecute in _beginthread

I need to run for example: ShellExecute(NULL, "open", "program.exe", NULL, NULL, SW_HIDE); as new thread, but I don't know how. I tried this: HANDLE hThread = (HANDLE) _beginthread(ShellExecute(NULL, "open", "program.exe", NULL, NULL, SW_HIDE), 0,…
Lukasz Re
  • 79
  • 1
  • 11
0
votes
0 answers

Destructor issue of shared_ptr, passed as argument to new thread

I pass params structure, which contains shared_ptr to std::deque, as input argument for function, which would work in a new thread. This deque created on the external object as a public field. And when I save shared_ptr to the params structure,…
3ka5_cat
  • 121
  • 1
  • 12
0
votes
1 answer

Pass parameter to _beginthread function

I have following code to start a new thread int number = 10; _beginthread(ModbusReadWrite, 0, (void*)number); The function is: void ModbusReadWrite(void *arg) { char inBuffer[BUF_SIZE]; int PointNumber = &arg; ... } It shows an error:…
user3048644
  • 93
  • 1
  • 5
  • 17
0
votes
2 answers

Passing Parameters to Function When Multithreading

I have an assignment to create a game like Frogger (you know - the game where a frog has to cross the street). So far I've created the logic behind the movement of the frog and the cars but I can't seem to run the processes simultaneously. I know…
0
votes
0 answers

thread(_beginthreadex) winsock(accept)

i wanna make a winsock non blocking object this is my code main function: #include #include #include "server.h" #include using namespace std; int main() { Object_server a; Sleep(100000); return…
Ken
  • 13
  • 1
  • 4
0
votes
1 answer

C++/Winforms threads: I get a build error with _beginthread

I'm new to threads and Winforms/C++. I would like to start a function in a new thread when I press a button. I was following this as a tutorial for threads. When I build the example code given on that site in a separate VC++ project, the build…
HaggarTheHorrible
  • 7,083
  • 20
  • 70
  • 81
0
votes
1 answer

The stack size argument in beginthread

I thought I knew what the stack size argument in beginthread means. So my question is: why does this work? #include #include using namespace std; void huge_stack(int a, int b, int c, int d) { int i[100000] = {0}; …
Borislav Stanimirov
  • 1,609
  • 12
  • 23
0
votes
2 answers

Multithreading with _beginthread in C++/CLI

I'm having a problem with _beginthread in microsoft visual studio c++ 10 express: my code: void __cdecl DashThread( void * Args ) // function without any class refs { while(1){ MessageBox::Show("work"); Sleep(5000); } …
Luke
  • 2,350
  • 6
  • 26
  • 41
-1
votes
1 answer

failing create a texture in a thread

In an application i am creating, i am using several textures which i load on demand. Till now i created them in the main process and everything works fine. Now i wanted to load them in a separate thread. So i call the function for loading and…
alfetta
  • 103
  • 2
  • 9
-1
votes
1 answer

c++ _beginthread can't pass string as a parameter

I would like to start multiple threads using a sample code like below: void ThreadFunction(void* param) { cout << (string)param << endl; _endthread(); } int main(int argc, char* argv[]) { for (unsigned int i = 1; i <= 10; i++) { …
TVA van Hesteren
  • 1,031
  • 3
  • 20
  • 47
-1
votes
1 answer

Launching 8 threads on 8core CPU doesnt' make 100% CPU load

I'm learning to use multithreading on a simple keygen example. I've implemented hashkeys matching algorhythm that increments one of the keys and compares it to the original and it should stop once two hashkeys match. So I need to iterate over…
Antiusninja
  • 157
  • 1
  • 17
1
2