Questions tagged [createthread]

70 questions
24
votes
2 answers

C , how to create thread using pthread_create function

I'm making a c file for a dispatch queue that gets a task and put it in to a queue which is the linked list. In order to do this, I need to create threads using pthread_t cThread; if(pthread_create(&cThread, NULL, work, param)){ perror("ERROR…
Leanne
  • 667
  • 3
  • 11
  • 23
9
votes
3 answers

How to pass integer to CreateThread()?

How to pass int parameter to CreateThread callback function? I try it: DWORD WINAPI mHandler(LPVOID sId) { ... arr[(int)sId] ... } int id=1; CreateThread(NULL, NULL, mHandler, (LPVOID)id, NULL, NULL); But I get warnings: warning C4311: 'type cast'…
BArtWell
  • 4,176
  • 10
  • 63
  • 106
7
votes
2 answers

multiple arguments to CreateThread function

When I use the CreateThread API method, what do I need to do when I want to pass more than one parameter where LPVOID lpParameter is passed?
Aneesh Narayanan
  • 3,220
  • 11
  • 31
  • 48
5
votes
2 answers

Function pointers in C++

I used CreateThread function to write a class like C# BackgroundWorker in C++.My code: BackgroundWorker.h: class BackgroundWorker { private : HANDLE _threadHandle; unsigned int _threadCallcounter; DWORD _threadID; …
4
votes
1 answer

Why can't a thread created by PowerShell execute script functions?

I have a script function that calls. net to manipulate word documents. It works. Now I want to create a sub-thread to execute it, and then the main thread decides whether it completes or exceeds the specified time, and ends it after that time. …
4
votes
1 answer

The Difference between to usages of SetWindowsHookEx

First: I'm using Visual Studio 2010 on Windows XP - 32 Bit. Right now I'm trying to write a DLL which will enable another application to work with low level keyboard hooks. Even though I got it to work - I now want to understand why. The non-working…
Daniel Heinrich
  • 790
  • 4
  • 12
3
votes
3 answers

Passing a parameter to CreateThread

I am having a problem passing a class reference as the parameter to the ThreadProc in a call to CreateThread. Here is a sample program that demonstrates the problem I am having: program test; {$APPTYPE CONSOLE} uses SysUtils, Windows,…
Kokonotsu
  • 189
  • 2
  • 9
3
votes
2 answers

Passing this pointer to CreateThread in class constructor behaves weird in thread procedure

In the constructor of one of my classes I call the Windows function CreateThread as last operation. The thread is created to execute immediately and I pass the this pointer of my class as lpParameter. In the thread procedure I cast the parameter…
felix
  • 61
  • 7
2
votes
2 answers

Difficulty passing struct through pthread_create

I have an array of structs and I intend to pass each element of the array into separate pthreads in a for loop. Here's my struct: struct arrayData{ int *a; int *b; int up, low; } Here's the pointer to the first struct and a malloc (don't know if I…
Chucky
  • 1,701
  • 7
  • 28
  • 62
2
votes
1 answer

CreateThread in DLL Terminating Prematurely

I am trying to load a DLL from Console Application. The simple console application is shown below: #include #include int main(){ HMODULE handleDll = LoadLibraryA("C:\\Tools\\TestDLL.dll"); if (handleDll) { …
valkyrie
  • 51
  • 8
2
votes
1 answer

Multithreading non-static in class C++

I am developing an application for Windows in which required run three processes:_thread_EEG (acquisition), _thread_MachineLearning (processing), _thread_Interface (interface). The second process uses data by the first process, and third process…
Victor
  • 23
  • 5
1
vote
0 answers

Mingw32 strange linker warning

This is the warning: Warning: resolving _worker by linking to _worker@4 Use --enable-stdcall-fixup to disable these warnings Use --disable-stdcall-fixup to disable these fixup The function worker is the start routine for the CreateThread. This is…
Metz
  • 675
  • 1
  • 9
  • 17
1
vote
1 answer

problems using CreateThread on a member function

I am trying to create a thread in an object, however I get an error saying '&' : illegal operation on bound member function expression. Reading up I saw I have to make the member function static, but when I do that I get an error saying left of…
fotg
  • 639
  • 1
  • 12
  • 25
1
vote
1 answer

How to call custom callback function in CreateThread?

I want to use CreateThread function but with my own custom callback function, this is how I am using it HANDLE handle = CreateThread(0,0,custom_function, NULL,0,NULL); declaration of custom_function DWORD custom_function(void) { printf("Hello…
loaded_dypper
  • 262
  • 3
  • 12
1
vote
1 answer

correctly terminate a running thread which "works"

I have a thread like this: DWORD WINAPI message_loop_thread(LPVOID dummy) { MSG message; while (GetMessage(&message, NULL, 0, 0)) { TranslateMessage(&message); DispatchMessage(&message); …
Stefan Hasler
  • 125
  • 1
  • 2
  • 5
1
2 3 4 5