|
Thanks,
I tried just ("%4X", year) but that didn't do it. Now I know.
Thanks again
Ryan
|
|
|
|
|
Hi,
I'm writing a multithreaded app and I'm having some bizzare problems. I have a worker thread which has a critical section. As the application starts up, it locks a whole bunch of times, and unlocks a whole bunch more times, no problems, every single lock is followed by an unlock. Then I call Sleep, after I've called sleep, I try and lock the CCriticalSection again, and the worker thread hangs permanently. This is bizzare because I've put TRACE0s in every single function that has access to that critical section, and none of them are called while my worker is sleeping. It's like somehow my critical section is getting locked, even though nobody seems to be locking it. Does anyone have any bright ideas about how my CCriticalSection might be being locked without me realising it? Is there any good way of knowing when and who is locking my critical section?
Joel Holdsworth
|
|
|
|
|
Bizzare! Replacing the CCriticalSection with a CMutex made the problem go away !?!
Joel Holdsworth
|
|
|
|
|
That's weird.
The main differences between critical sections and mutices is (a) mutices work cross-process, and (b) have a different timing.
I suspect you still have a bug lurking in your code, that is hidden / uncovered depending on timing.
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Agreed, however I time is not a luxury I have right now! I am seriously short of time.
Joel Holdsworth
|
|
|
|
|
what do u mean by sleep. You called Sleep()? That freezes the thread! You should never use that func if you want the thread to be able to process something else at the same time!
|
|
|
|
|
so let me understand this, you call each worker from your main process, then sleep in main? this s what you should do, but i suspect this is not the case...
a 'good' model:
while(1) {
// call your threadproc
sleep(L5);
// watever else
}
dont use sleep in threadproc, this suspends execution
|
|
|
|
|
No No! The worker does the sleeping! The main process never stops - it just runs the message pump!
Joel Holdsworth
|
|
|
|
|
Main process and the worker thread are both threads. You call Sleep in the w-thread, it will be suspended there sleepting, and not able to receive and new message. I assume your w-thread does task when told, i.e. when getting a message to trigger execution of certain functions. If your w-thread cannot receive message, no wonder your func does not get called, let alone hit your critical section.
|
|
|
|
|
Well, sleep() only sleeps for the time specified. As I understand the OP he has something like
<br />
...<br />
sleep(sometime);<br />
myCriticalSection.Lock()
here the sleep() call will only block the worker thread for sometime milliseconds and are thus not in itself a problem.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
thats the problem then, Sleep() suspends threads and may mess with the crit sect timing, movr Sleep() to main() and that should fix your issue. why do you sleep in worker threads anyway? do u see the oxymoron?
|
|
|
|
|
If, while debugging the code, the app hangs hit break (not stop).
By looking at the threads you can see what each is executing.
Put the CCriticalSection in the variable watch list and open it up.
Inside you should find the root critical section object.
One of the members of this structure is the owning thread.
Look in the debugger thread list and see what that thread is doing.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
i'm able to add methods to an Interface that returns integer value, like i declared
[Add method]
method name : MathAdd
parameters : int x,int y,[out,retval]*int sum;
[/Add method]
and the implementaion,
[implementation]
STDMETHODIMP StATL::MathAdd(int x, int y, int *sum)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*sum = x + y;
return S_OK;
}
[/implementation]
and i'm using this in a VB application thru referncing.
Now, how do i make a method thats gonna return a char value,
i tried like ,
[Add Method]
Method Name : ReturnString
Parameters : char * inpString,[out,retval]char *outString
[Add Method]
[implementation]
STDMETHODIMP StATL::ReturnString(char *inpString, char *outString)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
strcpy(outString,inString);
return S_OK;
}
[/implementaion]
but i get the following errors,
[stinker]
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1827) : error C2259: 'CComObject' : cannot instantiate abstract class due to following members:
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator >::CreateInstance(void *,const struct _GUID &,void
** )'
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1827) : warning C4259: 'long __stdcall IStATL::ReturnString(unsigned char *,unsigned char *)' : pure virtual function was not defined
d:\proj\stratl\stratl.h(80) : see declaration of 'ReturnString'
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator >::CreateInstance(void *,const struct _GUID &,void
** )'
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1827) : error C2259: 'CComObject' : cannot instantiate abstract class due to following members:
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator >::CreateInstance(void *,const struct _GUID &,void
** )'
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1827) : warning C4259: 'long __stdcall IStATL::ReturnString(unsigned char *,unsigned char *)' : pure virtual function was not defined
d:\proj\stratl\stratl.h(80) : see declaration of 'ReturnString'
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator >::CreateInstance(void *,const struct _GUID &,void
** )'
[/stinker] ..
how to go
plz note : this is my first attempt in ATL ,i was fooled when i searched for a "Hello World ATL"
thanks in advance
V
|
|
|
|
|
char is by default "signed" in VC, and "unsigned" in MIDL.
(giveaway: the compiler misses a function 'long __stdcall IStATL::ReturnString(unsigned char *,unsigned char *)' )
However, to pass strings across a COM interface, your MIDL declaration is not sufficient. (The bad thing is that in most cases it will go well, but can fail in another scenario quickly).
zero-terminated strings (those used in C) are not natively supported in COM. Though you can coax MIDL into using them, many clients will have problems with this.
The normal way to pass strings through a COM interface are BSTR strings. They are unicode strings, and must be handled using SysAllocString and it's companion functions.
Here are the basic rules of working with BSTR's:
- You must not free your [in] BSTR. the pointer is valid only during the function call (if you need to store the pointer, you need to copy it)
- You must "allocate and forget" the [out] BSTR
- NULL is a valid BSTR and must be treated like an empty string
VC offers a support class, _bstr_t that makes handling BSTR's (mostly) easier.
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Is there a C function to assign a file association in windows? I would like to pass as arguments a file extension and a path of the application which it would be associated with. ( open with ).
Just livin a dream.. dont wake me!
|
|
|
|
|
If you are using MFC, check out CWinApp::EnableShellOpen() and CWinApp::RegisterShellFileTypes() .
If not, you'll need to add some stuff to the registry manually. A basic .reg file looks like:
REGEDIT
HKEY_CLASSES_ROOT\.dbc = David.Document
HKEY_CLASSES_ROOT\David.Document\shell\open\command = DAVID.EXE %1
HKEY_CLASSES_ROOT\David.Document\shell\open\ddeexec = [open("%1")]
HKEY_CLASSES_ROOT\David.Document\shell\open\ddeexec\application = DAVID
; note: the application is optional
; (it defaults to the app name in "command")
HKEY_CLASSES_ROOT\David.Document = David Document Where David is the name of your application that handles the .dbc extension.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
DDE is just one of three ways that the Shell can invoke a verb. The ddeexec subkey is added to the verb's key to specify that a DDE conversation should be initiated.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I want to do a live update of software, but for some reason,
instead of going to the internet and downloading the file, on some
computers it goes to the temporary internet files folder and
just reloads that file so that it didnt update anything (but
the user thinks it did).
If I manually delete the file from the temporary internet files
folder and click Live Update, then everything works fine. So
my question is: how can I delete a file from the temporary
internet files folder? The file I want to delete, for me,
is:
C:\Documents and Settings\Danielle Brina\Local Settings\
Temporary Internet Files\Multiscreen.txt
But for other people on other computers, instead of my naming
showing up as a subfolder, they are going to have their name.
And I don't know what that is. Is there anyway to know what
this name is or folder is so that I can then go to the
other folders and delete the file?
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
|
|
DanYELL wrote:
instead of going to the internet and downloading the file, on some
computers it goes to the temporary internet files folder and
just reloads that file
Specifying the INTERNET_FLAG_RELOAD flag will force a download of the requested file from the server instead of trying to load a cached version.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I use this code:
hr = URLDownloadToFile ( NULL,
sURL, // URL to get
sFile, // file to store data in
0, // reserved
&callback // ptr to IBindStatusCallback
);
Is there anyway to specify that flag, INTERNET_FLAG_RELOAD, with
the function URLDownloadToFile or so I need to use
CInternetSession to download a file with that flag so that it
bypasses the cache?
Please, any response you can give me will be greatly appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Unfortunately, the flag applies to HttpOpenRequest() and InternetOpenUrl() (among others) but not URLDownloadToFile() .
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I have a MFC App with a Tray Icon. On Right clicking the Tray Icon i get a small 'Exit' menu and then on clicking on that i need to exit the App, but thats not happening, and the second time i click there's an assertion.
On the handler for the Exit button, i call DestroyWindow();
Also i am overloading the WM_WINDOWPOSCHANGED as said in this article.
http://www.codeproject.com/dialog/dlgboxtricks.asp
Any help here?????
Pritam
|
|
|
|