|
The code will have one instance but data will have one instance for each appliction that is using the dll. You can use a shared data segment to share data between processes if you want, in this case this data will only have one instance.
John
|
|
|
|
|
|
Hi,
I am using DDE (Dynamic Data Exchange) protocol to send data from my system to another system in my network. I dont know any forums which give programming support for this protocol and hope somebody here helps me in it... Back to my question,
I wanted to automate the data sending process and so I have a loop in my thread with a waitforsingleobject function . whenever new data arrives the object is signaled and data is thus transfered.I have a problem here The data is not transferred as such, but when I include a Afxmessagebox somewhere inside the loop.It works perfectly ok. I had to quit the box everytime.
what difference does the AfxMessagebox does ?
I dont understand it.Can anyone help me in it?
Thanks.
Deepak Samuel
|
|
|
|
|
Maybe the message box is giving somewhat a Sleep equivalent and is permitting the arrival of the data to the other system?
I suspect its a timing issue
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi,
Thanks for the reply.
I even tried introducing a sleep in the loop instead of the AfxMessageBox but it didnt work that way.
|
|
|
|
|
Hello,
I have a little question regarding CriticalSection:
I have a resource that is protected by a CCriticalSection variable.
let's say that the CriticalSection variable has an owner.
Now, another thread is trying to access the resource, and as expected - locked.
My question is: if an additional event took place, and as a result, the locked thread needs to exit the waiting, and perform some other activities (not related to the locked resource), how can I exit the attempted lock?
Is it possible?
Thanks...
He didn't fall?
Inconceivable!!!
|
|
|
|
|
Check WaitForMultipleObjects and WaitForMultipleObjectsEx
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
no, that won't work because a critical section is no object with a handle, it is a memory structure. There is a function called TryEnterCriticalSection , this should be the right choice here.
Don't try it, just do it!
|
|
|
|
|
I never said he should use it with a critical section
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
he was talking about one!
Don't try it, just do it!
|
|
|
|
|
I read his post, that why i answered
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
just accept that your answer was not the best one and don't argue with me!
Don't try it, just do it!
|
|
|
|
|
Quite lame
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks for everyone response..
I need to use criticalsection due to the following facts:
1. Mutex is signaled off after a task that took ownership ends, and I need the status to be on.
2. events are not good since i have several tasks waiting on the Critical Section , and the order of arrival is important
what I thought about doing is to create a temp thread that locks the critical section, while the main thread is waiting for several events (the temp thread receives reference to the critical section, as well as a reference to an additional event)
now, if the temp thread actually took control of the critical section, it ends normaly, and the wait command in the main thread is ended due to that.
The really interesting situation is when the temp thread is trying to lock the critical section, and the critical section is already locked - so the temp thread is waiting.
Now, I'm receiving another event, that is causing the wait on the main thread to finish - but the temp thread is still up and running.
I've found out that if, after we are exiting the wait, I'm performing Unlock to the critical section, the attempted lock is finished.
Am I correct?
He didn't fall?
Inconceivable!!!
|
|
|
|
|
To do what you are asking you will have to replace the CRITICAL_SECTION with a waitable event of some form. Then you can use WaitForMultipleEvents to wait for both the currently CRITICAL_SECTION protected resource and for the other events that may take place.
It seems to me that this scenario may imply that it's worth considering the design of your app, just to be sure there isn't a simpler solution. I treat CRITICAL_SECTIONs as efficient lightweight objects used to protect shared resources that aren't held very long.
Paul
|
|
|
|
|
Actually you could do a 'TryEnterCriticalSection' followed by a 'WaitForMultipleEvents' for your other events with a short timeout and repeat until done. But this is a clunky design. We shouldn't be spinning unless we have good reason deep in the kernel.
Paul
|
|
|
|
|
HI,
How can i access resources (printer / Cam etc) of other machine/PC on network provided that i already know the IP of that Machine/PC.
reply thanx
|
|
|
|
|
are you sure we are allowed to do so ?
TOXCCT >>> GEII power
|
|
|
|
|
If I understand your question, the resources on the machine in question would need to be shared.
In the Local Area Connections Properties dialog, make sure File and Printer Sharing for Microsoft Networks is listed in the Components box. On the machine that wants to use the resource, when asked for the name and/or location of the device, use something like \\a.b.c.d\resource_name.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Dear Mr Bhavani;
Thank you for the help that you have given me in accessing a public variable from anywhere within my application. The problem is that the code did not work at all. The compiler strongly complained when i added these code:
((CDatastructorView *) AfxGetMainWnd())->m_main.Navigate"file://c:/datastructor/lectures/recursion_implementation.htm",0,0,0,0);
CDatastructorView is my view class and m_main is a web-control which i want to use.
The compiler responded as :
:\datastructor\lefttooldlg.cpp(1296) : error C2065: 'CDatastructorView' : undeclared identifier
C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')'
C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')'
Ps. I have tried whatever Mr Davy and Mr Chen told me but when i include the "datastructorView.h" file within lefttooldlg, i have a few errors telling me that some "doc" stuff are not recognised....
Could you please help me out because i am still pretty at lost.
Krugger
Krugger
|
|
|
|
|
Redo what Mr Davy and Mr Chen and report the errors here
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
datastruct wrote:
Ps. I have tried whatever Mr Davy and Mr Chen told me but when i include the "datastructorView.h" file within lefttooldlg, i have a few errors telling me that some "doc" stuff are not recognised....
Due to the way the MFC AppWizard builds files, you will also have to include datastructorDoc.h before you include datastructorView.h
datastruct wrote:
((CDatastructorView *) AfxGetMainWnd())->m_main.Navigate"file://c:/datastructor/lectures/recursion_implementation.htm",0,0,0,0);
This looks wrong to me. AfxGetMainWnd returns a pointer to the m_pMainWnd which in a DocView architecture is usually the CMainFrame class.
I suspect your code needs to be more like this
CMainFrame* pFrame = (CMainFrame*) AfxGetMainWnd();
if(pFrame != NULL)
{
CDatastructorView* pView = (CDatastructorView*) pFrame->GetActiveView();
if(pView != NULL)
{
pView->m_main.Navigate"file://c:/datastructor/lectures/recursion_implementation.htm",0,0,0,0);
}
}
Michael
CP Blog [^]
|
|
|
|
|
The compiler responsed that erros because you did not include header file of CDatastructorView class in lefttooldlg.cpp.
In spite of you have done as few guides but errors stilled occurring. It can be that you did not included header correctly.
I guess that you have included header file in dialog implementation file, so compiler complained about GetDocument member function which declared in such header file.
In this case, you should include document header file (I guess it may be DatastructorDoc.h ) before view header file.
<br />
#include "DocHeader.h"<br />
#include "ViewHeader.h"<br />
There are few others way can help you resolve that problem.
If you need to include view header file in dialog header file:
In header file of dialog, at before dialog declaration, declare:
<br />
class CDatastructorView;<br />
In dialog implementation file (cpp), include CDatastructorView header file at before DatastructorView.h such below:
<br />
#include "DatastructorView.h"<br />
#include "dialog.h"
Good luck
|
|
|
|
|
Errrr, stupid question:
((CDatastructorView *) AfxGetMainWnd())->m_main.Navigate("file://c:/datastructor/lectures/recursion_implementation.htm",0,0,0,0);
Isn't there missing this bracket right after "Navigate"?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
I am trying to open a file on windows 2000 using CreateFile as follows, and I am getting error 32 (The process cannot access the file because it is being used by another process.).
hFile = CreateFile( lpszName,
GENERIC_READ ,//| GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
Surprisingly, I can open the same file using gvim.exe but not wordpad, notepad or even Visual studio?
Thanks for any ideas.
~f
|
|
|
|