Questions tagged [beginthreadex]

28 questions
9
votes
2 answers

Can I call CloseHandle() immediately after _beginthreadex() succeeded?

I'm not interested in using the handle returned from _beginthreadex(). Is it safe to call CloseHandle() on it immediately? I believe this must be done to avoid memory leaks.
user1061590
  • 185
  • 2
  • 4
8
votes
3 answers

How to safely close a THREAD which has a infinite loop in it

I am creating a thread using _beginthreadex function. The function address I am passing in it has an infinite while loop (while(1)) . I have the threadid and threadhandle. I can use TerminateThread(threadhandle,1); But it is dangerous. The safe…
lsrawat
  • 157
  • 3
  • 9
5
votes
4 answers

How can I pass boost::shared_ptr as a pointer to a Windows Thread function?

How can I pass boost::shared_ptr as a pointer to a Windows Thread function ? assume following code : test::start() { .... _beginthreadex( NULL, 0, &test::threadRun, &shared_from_this(), 0, &threadID ); ... ... } /*this is a static…
Behrouz.M
  • 3,445
  • 6
  • 37
  • 64
3
votes
2 answers

Multithreading: thread or process.h - C++

I started studying multithreading. And I've found 2 ways to use it ic C++. First is by thread #include ... std::thread t(function); << some code>> t.join(); //(or detach) And second is by process #include…
3
votes
3 answers

DirectShow - Unable to create new threads

I am having some strange issues integrating a DirectShow graph into an existing application. A couple things to cover first: The graph's purpose is to bring raw video from a FrameGrabber which has an exposed DirectShow interface. The graph takes…
DeusAduro
  • 5,971
  • 5
  • 29
  • 36
2
votes
1 answer

pass more than one parameter to _beginThreadEx

Is it possible to pass more than one parameter to beginthreadex? I know I can create a class or structure, but what if I have unrelated pieces of data that I don't want to combine into a class or structure? Boost libraries seem to allow for multiple…
thistleknot
  • 1,098
  • 16
  • 38
1
vote
2 answers

std::vector does not release memory in a thread

If I create a thread with _beginthreadex, and in the thread I used std::vector that consumes 200MB of memory - when the thread ends, the memory is not released. Even after CloseHandle, the memory is not released. Here is a working…
JeffR
  • 765
  • 2
  • 8
  • 23
1
vote
2 answers

C++: _beginthreadex, thread function name not showing in Visual Studio Threads window

I recently learnt that ::_beginthreadex() is always preferable to ::CreateThread(), so I changed all my calls that used ::CreateThread(). The only downside is that I no longer see the thread function's name in Visual Studio's Threads window making…
1
vote
1 answer

class with Multithreaded member function

I have a class which I am trying to convert some of its member function to run in different threads. While the program complies without problem, but it crashes when it is trying to read from a image buffer(which is updated by a different thread). …
CodeAsIGo
  • 13
  • 4
1
vote
1 answer

passing PVOID array, containing multiple type variables to _beginthreadex()

I want to pass an HANDLE and a HWND variables to a _beginthreadex function, I don't want to set those variable global. that's what i've tried : int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd) { …
LAVR
  • 13
  • 4
1
vote
0 answers

How to end a specific thread which was initialized by _beginthreadex

i want to Close the thread which was initialized by the _beginthreadex. as i am also using Qt for GUI so when i use _endthreadex() then it Closes all threads which are running but i only want to Close or Exit the thread which was began by the…
1
vote
2 answers

Calling _beginthreadx with Passing function Pointers

I'm interested to know if it is possible to call _beginthreadex with function pointer that is not known and NOT based on class design. For example: #include #include #include int myThread(void* data) { …
1
vote
1 answer

CInternetSession close thread handle

I try to create simple app, which Write/read files on FTP server. I create a thread HANDLE hThread; unsigned threadID; hThread = (HANDLE)_beginthreadex( NULL, 0, &foo, NULL, 0,NULL ); CloseHandle( hThread ); A function foo()…
alinaish
  • 456
  • 2
  • 7
  • 18
1
vote
3 answers

Error of argument type with _beginthreadex

To define my thread I have in my Header file: class HttpClient { public: ... unsigned int __stdcall PerformLogin(void*); ... }; Then in my cpp file I have: unsigned int __stdcall PerformLogin(void*){ ... } And to call this thread I…
darkheir
  • 8,844
  • 6
  • 45
  • 66
0
votes
2 answers

_beginthreadex cannot convert from 'overloaded-function'

So I was making a function to print text layered across a different window, and I wanted it to be in a separate thread so I can run a timer for the text to display while leaving the user open to continue using the program. However, when I compile I…
Tox1k
  • 105
  • 8
1
2