Questions tagged [beginthread]

30 questions
10
votes
1 answer

Interview: what is the difference between pthread and windows thread created by _beginthread(ex)?

I was asked about this in an c++ developer position interview, what is the answer to this?
Leon
  • 8,151
  • 11
  • 45
  • 51
6
votes
1 answer

BeginThread Structure - Delphi

I've got a almost completed app now and the next feature I want to implement is threading. I chose to go with BeginThread(), although am aware of TThread in delphi. The problem I'm coming across is the structure of BeginThread() call. Normally the…
Flatlyn
  • 2,040
  • 6
  • 40
  • 69
6
votes
3 answers

Visual C++ Threads Simple Example

I am trying to create a basic thread from main by passing a function to _beginthread. But My output is not getting completed. I am getting the following output: Starting thread 48 Main ends I Could someone please clarify what is wrong in the…
TechyHarry
  • 301
  • 2
  • 8
  • 25
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
0 answers

C++ Passing struct to a function between threads

I'm facing a weird problem. I have the below struct and the method that uses the struct. struct AsyncData { string documentNo; string command; string filePath; }; UINT AsyncDownloader(LPVOID pData) { AsyncData* ad =…
Siva Kumar
  • 41
  • 4
2
votes
2 answers

How to get the return value of the first parameter _StartAddress of function _beginthread

I wanted to do something using multi-threading and all the stuff encapsulated in function foo . filterThread = _beginthread (foo, 0,NULL) ; and I wanted to let foo return value: int foo() { return iRet; } but the prototype of _beginthread…
fr33m4n
  • 542
  • 2
  • 13
  • 31
2
votes
2 answers

Understanding the MSDN _beginthreadex function example

There's this function on _beginthreadex MSDN page: unsigned __stdcall SecondThreadFunc( void* pArguments ) { printf( "In second thread...\n" ); while ( Counter < 1000000 ) Counter++; _endthreadex( 0 ); return 0; } I know you…
c00get
  • 23
  • 3
2
votes
0 answers

Beginner Visual C++ Issue: cannot convert parameter 1 from 'void (__cdecl *)(void *)' to 'void (__cdecl *)(void *)'

So I'm a predominantly Linux programmer who's recently got a job working with Windows. I've developed some numerical code, but now need to put a simple GUI on. At the moment I have a button with an onClick event with calls a function called start…
James
  • 3,957
  • 4
  • 37
  • 82
1
vote
2 answers

Starting a method in another thread C++

I'm having trouble finding out how to run a method in a seperate thread in C++ (using Visual C++ 2008), I've tried a number of ways to do this but none of them so far have been successful. I'm very new to C++ but a fairly experienced programmer in…
1
vote
3 answers

Using regex in perl to extract a substring, or line from a blob of text

I have a variable with some blob of text in it $foo = " Garbage directory /test/this/is/a/directory /this/is/another/foo\nThisd is is\nDrop stuff testing\nRandom stuff emacs is great"; How do I use regex to get the line that is…
1
vote
2 answers

Delphi, Passing Pointer through BeginThread

I am creating a thread using BeginThread. In the procedure I am using to start the thread I want to pass a pointer to a boolean variable so that both the forked thread and main thread can access it as a control variable to tell one when the other is…
Tim
  • 1,549
  • 1
  • 20
  • 37
1
vote
2 answers

Windows Threading: beginthread or QueueUserWorkItem (C++)

I am wondering whether to use beginthread or QueueUserWorkItem for threaded methods in C++. What are the differences between the two APIs and in what context are they better suited? Thanks, BTW, I have read this question Windows threading:…
Robben_Ford_Fan_boy
  • 8,494
  • 11
  • 64
  • 85
1
vote
1 answer

Passing arguments to _beginthread within class function

I've been using _beginthread within my (windows) C++ class to create threads. As I have learned, to use _beginthread and pass a member function within a class, there is a rather obtuse wrapping protocol that has to be followed, for example: class…
cmgurba
  • 45
  • 6
0
votes
1 answer

Can't compile a C++ program with _beginthreadex

#include #include #include //#include "windowstate.cpp" //DWORD WINAPI MyThreadFunction( LPVOID lpParam ); using namespace std; int Zeit; unsigned int __stdcall wfshutdown() { Sleep(Zeit*60000); …
AaronP
  • 43
  • 1
  • 4
0
votes
1 answer

Passing values to a thread with _beginthread and avoiding C-style casts?

My program creates a thread but I'm getting a "Don't use C-style casts" in my code analysis with Visual Studio. #include #include #include void myThread(void * threadParams) { int* x =…
JeffR
  • 765
  • 2
  • 8
  • 23
1
2