Can anyone give me a little bit of information on multi threading in C++? Is there any easy-ish way to do it?
It's not too complicated in Java... I'd even recommend learning it first there.Threading is complicated in just about every language but can (usually) be simply avoided...
Threading in .Net is actually fairly easy as well, the only problem I have is Mutex (MUTual EXclusion), and interacting between the main thread and so on.What are you looking to accomplish?
Threading is complicated in just about every language but can (usually) be simply avoided...
Post what you're using? I'm pretty sure I've done that or something very similar before it was wasn't that badly performing.My problem is, I am trying to grab the source of a page and then find one string in it, the function I am using is just too slow.
string GetSource(char m_strURL[])
{
if ( m_strURL == "" )
{
return "";
}
HINTERNET hINet, hFile;
hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if ( !hINet )
{
return "";
}
hFile = InternetOpenUrl( hINet, m_strURL, NULL, 0, 0, 0 ) ;
string m_strContents;
if ( hFile )
{
CHAR buffer[1024];
DWORD dwRead;
while ( InternetReadFile( hFile, buffer, 1023, &dwRead ) )\
{
if ( dwRead == 0 )
break;
buffer[dwRead] = 0;
m_strContents += buffer;
}
InternetCloseHandle( hFile );
}
InternetCloseHandle( hINet );
return m_strContents;
}
That's pretty much functionally equivalent to the code I'd been using. I thought you were saying that searching for the string was slow but I now realize you mean that getting the source is slow and I had that same issue. It's late right now but I'll see if I can write up a better get source tomorrow or the next day using socket programming.
EDIT: What compiler do you use and what Operating System are you running?
This is sort of off-topic, but may I suggest Code::Blocks? It is a much more up-to-date IDE with a lot more functionality. Dev-C++ is so featureless it's not funny IMHO.Windows Vista and Dev-C++. I will be moving on to VC++ soon enough, but my class requires me to use Dev.
This is sort of off-topic, but may I suggest Code::Blocks? It is a much more up-to-date IDE with a lot more functionality. Dev-C++ is so featureless it's not funny IMHO.
I'll take a look at your code later as well, although I'm not familiar with Windows functions. I tend to use 3rd-party libraries so I can port things.

