|
Tried the critical section but when it tries to lock in the main thread, everything hangs for some reason. I think the message pump may be getting blocked. Used critical sections a lot in my server code and they work great. For some reason it doesn't seem to want to cooperate with graphics routines.
|
|
|
|
|
I'm going to guess you have one path in the thread which doesn't release the critical section.
If that doesn't work, try running around your office screaming and waving your arms in the air.
|
|
|
|
|
lol tried both. The screaming worked better than the critical section. I checked all the paths, only use it in one place in each thread. Had that happen before so it was the first thing I thought to check. Very perplexing problem.
|
|
|
|
|
Yes, but was it a manly scream or a high-pitched girly scream? I've found that only high-pitched girly screams help with threading problems.
Seriously though. Could you post some of your code?
Software Zen: delete this;
|
|
|
|
|
Messages for a window can be processed only by the thread that created the window. That's how message pumps work. Designing you code so that another thread updates the UI will likely result in other problems (or at the very least, inefficiencies when the threads have to wait on each other).
But sticking with your question, if the worker thread is the only one touching the back buffer, why do you need a lock at all?
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Thanks for the info. The back buffer is processed by the paint routine in the main thread as well. What's the best way to handle multi-threaded graphics to a dialog window?
|
|
|
|
|
Maybe I can explain it better. Only the main thread that created the dialog processes messages. The worker thread only updates only the back buffer which is then processed by the main thread and updated to the screen.
|
|
|
|
|
Hi all,
I've created a release version of an application which uses MFC and when deployed on my test machine I get the error:
"The dynamic link library MSVC60.dll could not be found in the specified path ...."
I know what the error means, but why in the heck is it looking for this file? I thought the release build was independent of the Visual Studio dlls. What do I need to do in order to correct this problem?
|
|
|
|
|
will1383 wrote:
I thought the release build was independent of the Visual Studio dll
only if you build with static linking. (Project / Settings / General - in VC6)
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
What's really strange though is that I've been using dynamic linking all along, and have had no problems what-so-ever.
Strange. I'll try a static build for kicks.
|
|
|
|
|
The debug DLL (MSVC60D.DLL) may be installed but not the non-debug DLL.
|
|
|
|
|
use the visual studio installer, and include msvc60 as a merge module, that should solve your problem right there.
hey
|
|
|
|
|
I'm writing a program that gets a computer name from a list of IP address. The first time thru it gets the computer name without a hitch. From then on I keep getting a error.
Here is a snippet of my code that does the gethostbyaddr.
}<br />
LPHOSTENT lphp;<br />
struct in_addr in_addrIP;<br />
<br />
<br />
<br />
if (!InitSocket()) <br />
{<br />
AfxMessageBox("Error initializing WSAStartup", MB_OK | MB_ICONSTOP);<br />
return -1;<br />
}<br />
<br />
in_addrIP.S_un.S_addr = inet_addr(szAddress);<br />
lphp = gethostbyaddr((char FAR *)&in_addrIP, sizeof(struct in_addr), PF_INET);<br />
<br />
if (lphp == NULL)<br />
{<br />
AfxMessageBox("Failed at gethostbyaddr", MB_OK | MB_ICONSTOP);<br />
return -1;<br />
}<br />
<br />
WSACleanup();<br />
<br />
return lphp->h_name;<br />
<br />
<br />
}
Am I supposed to initialize something before I give it another address to try?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Yes, you must reinitialize winsock after WSACleanup().
Kuphryn
|
|
|
|
|
I am. Each time I drop into this fuction it runs the InitSocket().
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Which does what? The counterpart to WSACleanup() is WSAStartup(). If your "convert" function is being called multiple times, I'd move the calls to WSACleanup() and WSAStartup() so they are only called once.
|
|
|
|
|
Understandable. I'll try that. Although that should not make a difference since each time I come out of this function I clean up the socket. And each time I come into it with a new ip address, it's initialized.
There may be some resouce overhead with doing it this way which is why I may take up your suggestion and move it out of this function and only do it once, but this still does not fix my problem.
Any other suggestions?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
Any other suggestions?
Not without knowing what InitSocket() does. If it calls WSAStartup(), which might be failing, what does WSAGetLastError() return?
In your original post, you state that "From then on I keep getting a error." but give no indication as to the error or the line causing it.
inet_addr() can return INADDR_NONE but there is no check for that.
gethostbyaddr() can return any number of errors, but none are being checked for. Call WSAGetLastError() to find out.
|
|
|
|
|
David
Thanks for the quick response.
InitSocket =
<br />
WSADATA wsaData;<br />
int retVal = NULL;<br />
<br />
retVal = WSAStartup(MAKEWORD(2,2), &wsaData);<br />
<br />
if(retVal)<br />
{<br />
return -1;<br />
}<br />
<br />
return 1;<br />
If initsocket comes back with a -1 then WSAStartup failed.
DavidCrow wrote:
In your original post, you state that "From then on I keep getting a error." but give no indication as to the error or the line causing it.
Yeah sorry for the confusion. Basically it's failing at the gethostbyaddr.
I guess I wasn't that clear in my subject line.
I haven't done a WSAGetLastError...brain freeze or something.
The way this app works is that I have a list of IP address. I get the first IP address and ping it. If it response then I drop down to this function and get the computer name. Then come back to my calling function and get the next IP address. Ping it and if there is a response then I drop down to this fuction. If there is no response then drop to some other function.
My problem is that the very first time it comes to this function is works fine and returns back the computer name. The second, third, fourth, etc times it comes to this function it errors out.
I'll run the WSAGetLastError and see what I get returned back. I just thought that I need to initialize somthing that I wasn't
Thanks for the help
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
David
I found my problem. Sometimes I feel really stupid.
First I put in my error checking function that calls WSAGetLastError. After it started going down my list of IP addresses it errored out after the first one with a strange error. After reading the error I realized....what if the ip addresses at the beginning of the list did not have a NETBIOS name?
So after looking at the ip addresses and trying different ones that I was sure was associates with a pc it worked fine. After further searching I found that the ones (ip addresses) that were erroring out were ones associated to ras servers and print servers. Not pc's but like the jet direct print server. DUH!!! I can't believe that I overlooked that.
Thanks for all the help. Sometimes it's worth posting on this forum just so that someone can give you that differnt look at the problem.
Thanks again
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Hi,
I asked this question a long while ago but all the suggestions were too complex for a beginner like me :P
anyway, basically, what is the easiest way to compare two files, given just their path names.
The best one i found on here seemed to have about 500 compilation warnings... vDiff i think it was called..
it's for a windows only program btw, if that makes a difference.
Thanks in advance, you could be lifesavers.
cheers
Col
|
|
|
|
|
The simplest is from the command line type:
fc /b file1 file2
(Of course, replace file1 and file2 with the appropriate file names.)
|
|
|
|
|
Hi Guys,
I am facing a problem while playing with different styles of the Edit Control. I want to toggle between the alignement styles ES_LEFT,ES_RIGHT and ES_CENTER at run time through selecting them through radio buttons. I have tried to do it through the following code, but it does't work in case of above stated style bit whereas the same code
works correct for ES_LOWERCASE and ES_UPPERCASE bits;
DWORD dwStyleOld;<br />
DWORD dwStyleNew;<br />
CRect rect;<br />
dwStyleOld = m_EditCtrl.GetStyle();<br />
dwStyleNew = dwStyleOld & ~ES_LEFT;<br />
dwStyleNew = dwStyleNew | ES_CENTER;<br />
m_EditCtrl.ModifyStyle(dwStyleOld, dwStyleNew);<br />
m_EditCtrl.GetWindowRect(&rect);<br />
InvalidateRect(&rect);
Regards,
Nasir Maan
|
|
|
|
|
Try something like this instead:
<br />
DWORD dwStyle = GetWindowLong( GWL_STYLE );<br />
dwStyle &= ~ES_LEFT;<br />
dwStyle |= ES_CENTER;<br />
SetWindowLong( GWL_STYLE, dwStyle );<br />
There are 10 kinds of people - those that get binary and those that don't.
|
|
|
|
|
sir,
I have tried it also...but unfortunately there is no success.
Regards,
Nasir
|
|
|
|