|
I have a misbehaving multithreaded application which works so so using CreateThread and associated code ( set priority etc.) I have changed to AfxBeginThread and cannot compile( always fails with 1 parameter not matching required parameters) it without changing my thread processing function to UINT ThreadProcessFunction(... I need this function to be
UINT CALLBACK ThreadProcessFunction(... ! I am monitoring events from COM port. The AfxBeginThread "calls" CreateThread - so why it does not work?
Thanks for reading.
Vaclav
|
|
|
|
|
Post some code, and you might get a better response...
|
|
|
|
|
i'm getting started on an emulator, and have a question about performance. Which is faster, using a game loop type of looping code, or running the cpu in a different thread (with synchronization issues to worry about). i.e.:
GameLoop:
WinMain(...) {
MSG msg;
do {
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
RunCpu(100000);
}
} while(msg.message != WM_QUIT)
return msg.wparam;
}
different thread:
void File_StartEmulation() {
DWORD threadId;
if(!CreateThread(NULL, 0, &CpuLoopThread, NULL, 0, &threadId)) {
ShowErrorMessage();
}
}
thanks alot for any help
|
|
|
|
|
Doing your processing in a PeekMessage loop is very 1990's. It will impact on the responsiveness of the app and you won't get predictable performance.
Writing multi-threaded code can be quite challenging, but is the way to go, for anything but the simplist of tasks.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
|
|
|
|
|
|
Kixdemp wrote: What will the emulator emulate?
If he uses PeekMessage then it will emulate a multi-threaded program, very badly.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
|
|
|
|
|
i'll (hopefully) be emulating a low-powered desktop pc on a high-powered embedded device (a pocket pc), so i'll need as much speed as possible, which probably will involve assembly at some point. it'll be a monster! Though I already had a simple windows prototype, i'll be completely rewriting it for the pocket pc.
anyway, i guess for now i'll be going with the multithreaded version. wish me luck to get it off the ground.
|
|
|
|
|
|
I'm testing a DirectShow Filter
I'm including this code to initialize an COM object
hr = CoCreateInstance(CLSID_MPEGFilter,
NULL, CLSCTX_INPROC_SERVER,IID_IBaseFilter,
(void **)&m_pMPEGWriter);
I have included the header in my application so it compile ok.
But I get a link error
error LNK2001: unresolved external symbol CLSID_MPEGFilter
- How can I know if the object has been registered?
- I don't see any .lib to include just couple of DLL
Any idea what I can be doing wrong?
Thak You
Hector
|
|
|
|
|
In the Debug Watch window type "hr,hr" and you will see the description of error.
Nevertheless, don't forget to call CoInitialize(NULL);
Dudi
|
|
|
|
|
I can not go to de Debug Window at least I have an executable so I have to fix the link error first. Am I correct?
|
|
|
|
|
I think that you didn't understand me.
CoCreateInstance returns HRESULT. you defined hr variable as HRESULT.
Typing "hr,hr" in the Debug Watch window shows the error description.
|
|
|
|
|
Maybe if you use the #pragma import directove on the DLL that has the MPEG filter class object in it, then your unresolved external will go away.
No shirt, no shoes, no brains, no service.
|
|
|
|
|
Hi All.
I have difficulty to save the content of variable (e.g. 2 dimension array) to a txt file using visual c++ 6.0 MFC.
Sample case :
double pic[4][4]={0,1,0,1, 1,0,1,0, 0,0,0,0, 1,1,1,1};
and I want to save it to the txt file (e.g. myFile.txt) so that myFile.txt contains 0,1,0,1, 1,0,1,0, 0,0,0,0, 1,1,1,1 which is readable (non-binary format) when I open the file with notepad.
Can anyone help me to solve this problem ?
Thanks very much for your attention and help in advance
Regards
Ronald Ruly
University student in Singapore
|
|
|
|
|
I suppose you should use itoa() on your data (items in your array) and then simply write it down as a string.
---
http://sprdsoft.cmar-net.org - We Sprd You Softly
Our site features contents and several images. All of this is very weird.
In the end, war is not about who's right, it's about who's left.
|
|
|
|
|
Thanks Titan for your attention.
I have got the answer from my friend. The solution that I got from my friend is like this :
FILE *file=fopen("myfile.txt","w");
if (file != NULL)
{
fprintf(file,"scale:%d max:%d\n",6,4);
for(m=0;m<256;m++)
fprintf(file,"%d ",histogram[m]);
fclose(file);
}
I didn't know before that variable type FILE can be used for MFC, because I had always been overwhelmed by CFile that deals with the binary file IO.
Regards
Ronald Ruly
University student in Singapore
|
|
|
|
|
Hello,
I've write a little programm to get data from a server using CAsynSocket.
All is ok but when the server send :
1rt trame : HELLO1.HELLO2\n.
2nd trame : HELLO3\n.
3rt trame : HELLO4. (where '.' is a null byte)
I've got only :
1st call to Receive() : HELLO1
2nd call ............ : HELLO3
3st call ............ : HELLO4
So the socket do not cath the HELLO2.
I am using CommView to see the trame and sometimes this happen so I do not all the data
If someone can help me to understand what is wrong.. thanks in adavance.
Part of my code to get data :
void CMySocket::OnReceive(int nErrorCode)
{
char buf[4096];
int nRead;
nRead = Receive (buf,4096); // Receive data
....
}
-- modified at 9:16 Saturday 17th December, 2005
|
|
|
|
|
Hello.
I think the problem isn't in the socket handling, it's a display problem.
The "\0" (null) is a string terminator, so that's the reason why you just see "HELLO1".
|
|
|
|
|
#include <afxwin.h><br />
#include <typeinfo.h><br />
#include <iostream><br />
using namespace std;<br />
<br />
class CAge: public CObject<br />
{<br />
public:
int m_age;<br />
public:<br />
CAge(int paraAge)<br />
{<br />
m_age = paraAge;<br />
}<br />
~CAge(){}<br />
public:<br />
virtual void AssertValid() const;<br />
};<br />
<br />
int main()<br />
{<br />
CAge* pcage = new CAge( 21 );
ASSERT( pcage!= NULL );<br />
ASSERT( pcage->IsKindOf( RUNTIME_CLASS( CObject ) ) );<br />
<br />
cin.get();<br />
return 0;<br />
}<br />
<br />
<br />
shanzy<br />
<br />
-- modified at 9:01 Saturday 17th December, 2005
And the compiler tell me:
error LNK2001: unresolved external symbol "public: virtual void __thiscall CAge::AssertValid(void)const " (?AssertValid@CAge@@UBEXXZ)
fatal error LNK1120: 1 unresolved externals
|
|
|
|
|
|
Thank you for your tip,I forget to implement it,
shanzy
|
|
|
|
|
hi
i create 2 window in the SDI document using splitter..I need scroll bars ..But it's not happen..how can i add scroll bars..if i using CScrollBar
it's not working
sid
|
|
|
|
|
|
Whenever i debug a dll thru the main application the execution is not coming to the break point inside the dll and whenever i press shift+F5 it is showing "Preloaded symbols may not match <mydllname>.dll."
Please tell me what is happening.
Thanks in advance,
John
|
|
|
|
|
In your debug settings, under Additional DLLs, did you happen to add the DLL so that you may set breakpoints in it before running the application? If so, you may have provided the wrong DLL path.
This can happen if you specify a Debug configuration path (e.g. "C:\...\Debug\MyDLL.dll") whereas the application loads the Release configuration of the same DLL (e.g. from "C:\...\Release\MyDLL.dll"). Although the two DLLs have the same name, they are loaded as separate modules into memory. The breakpoints are set in the module that never gets a chance to run.
This can also happen if your DLL is a COM server (e.g. implements an ActiveX control). Whether the Release or Debug version of the DLL gets loaded depends on the last settings made in the registry. You need to lookup the CLSID of the implemented ActiveX control (HKEY_LOCAL_MACHINE\SOFTWARE\CLSID\yourclsid) and see what InProcServer DLL is registered - the release or debug version. Then, in your application's debug settings, you need to synchronize the specified DLL path to this.
Hope this helps.
|
|
|
|