954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Threads in dll

Hello
Im coding mp3 encode / ripping tool and because i have licence to realbasic im gonna make user interface with it Technical part im gonna make with akrip.dll and i have develope it more by my own way now. The meaning is use threads for ripping and encode in the same time and i have thinking to use _beginthread function. In the future im gonna develope that tool to use multicore processors. But now the problem is how to design threading because now all functions in the dll are called by their own way from a realbasic so there is no mainthread at all. How it is possible to plan threads to these functions? Or is it necessary make threading in realbasic?

Aleczz
Newbie Poster
7 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

You mention "realbasic" 3 times, and never mention C.
Are you in the right forum?

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 
You mention "realbasic" 3 times, and never mention C. Are you in the right forum?


But the main thing is how to make threads to dll functions if there is no main thread used. Dll has made by c- language.
Example:
dll include this function

void WINAPI HelloWorld()
{
  int i;
  for(i = 0; i < 5; i++)
  {
    printf("Hello world!!!");
    sleep(2000);
  }
}

Mainprogram.exe call dll and straight to this function. So is it possible to change the function to thread because i dont want to wait the time when function is ready? It totally jam the Mainprogram.exe.

Aleczz
Newbie Poster
7 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

Shouldn't matter in what language your DLL is made, I think you need to figure out how to thread in RealBasic and call the functions from your realbasic program.

Clockowl
Posting Whiz
376 posts since May 2008
Reputation Points: 69
Solved Threads: 28
 

try this example DLL: I compiled it but didn't test it

#include <windows.h>
#include <stdio.h>

static DWORD WINAPI myThreadProc(void* parmeter)
{
   while(true)
   {
      printf("Hello world!!!\n");
      Sleep(1000);
      }
   return 0;
}
   
__declspec( dllexport )  int WINAPI HelloWorld()
{
   CreateThread(0, 0, myThreadProc, 0, 0, 0);
   return 0;
}
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Ok, thanks. Realbasic is bad because it doesnt have real threads but I will try to find the way solve this with c.

Aleczz
Newbie Poster
7 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

I'm confused -- do you want the threads in RealBasic (whatever that is) or in the DLL? The code I posted will create the threads in the DLL and will work regardless of the language that calls it.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Yes, to dll, thanks for the code.

Aleczz
Newbie Poster
7 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You