|
Hi,
You might consider using a semaphore to control queuing/de-queuing so that the de-queuing thread does not consume any CPU while it is waiting for more items to process. There is an exellent Queue class on this site:
Using Semaphores: Multithreaded Producer/Consumer
By Joseph M. Newcomer
Its slick and very compact - you wont get much better that this.
Have fun.
Tony
|
|
|
|
|
Hello, In my App I need to do some processing prior to the system going into a sleep mode, and once again when waking up.
I have tried a number of different ways of implementing this, but haven't succeeded in sucessfully intercepting the message. The code for the current implementation is included below. My app is SDI, OS is Win2000.
LRESULT CADSL_LoggerView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if(message == WM_POWERBROADCAST)
{
CString szMsg;
BOOL bRC;
switch (wParam)
{
case PBT_APMSUSPEND:
szMsg.Format("Received PBT_APMSUSPEND");
g_pLogFile->Add(szMsg);
bRC = KillTimer(ID_TIMER);
szMsg.Format("KillTimer() returned %i",bRC);
g_pLogFile->Add(szMsg);
break;
case PBT_APMRESUMESUSPEND:
szMsg.Format("Received PBT_APMRESUMESUSPEND");
g_pLogFile->Add(szMsg);
bRC = SetTimer(ID_TIMER,300000,TimerProcs); // 5 mins (300 secs)
szMsg.Format("SetTimer(300000) returned %i",bRC);
g_pLogFile->Add(szMsg);
break;
}
}
return CChartView::WindowProc(message, wParam, lParam);
}
I have seen other messages go through the function, but a breakpoint after if(message == WM_POWERBROADCAST) never seems to fire on hibernation. Can anyone give me some idea of what's going wrong, and how to track it down ? Many thanks !
Doug
|
|
|
|
|
check the power configuration settings of the operating system
If it doesnt work check it on another PC, maybe on your old PC isnt all modern enough
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
It is definitely not an OS problem - the system does hibernate. Also, I know the WM_POWERBROADCAST message does get issued, as I can see it being "caught" by another project ("PowerLog" downloaded from website). So, it's definitely something to do with my implementation. For instance, does my code snippet have to be included in any particular class of the project ?
Doug
|
|
|
|
|
are you shure that your winproc is the active one of the main window?
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
There is only one view - normally hidden, I admit. Surely such a messsage (WM_POWERBROADCAST) still gets to a window even if it is hidden ? (or is this my problem ?)
Doug
|
|
|
|
|
For anybody that hits this problem, I thought that I would update this thread. By a process of trial and error, I found that the only class of my project that would recognise the WM_POWERBROADCAST message was CMainFrame (by overriding WindowProc() )
Doug
|
|
|
|
|
Hai friends
what is multithreading, and how to use in vc++, and how to tested it...
help me plz...
Best Regard's
Mathy's
|
|
|
|
|
This subject is way too broad be explained in message on a forum. I suggest you read through the articles available here on codeproject that talk about multithreading or to google for it. Or even better, to buy a good book on the subject. You can also have a look at this excellent article[^]
|
|
|
|
|
mathy wrote: what is multithreading
It is a really big topic, you're strongly encouraged to read a book about. For an introduction see [^], [^].
Multithreading is what you typically need, when, for instance, your program is performing I/O operations for a long time and you don't want the user interface hanging in the meanwhile.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yesterday you asked us to "explain" COM, ATL and MFC. Now you're ready for multithreading.
Will you PLEASE do everyone here a favour by buying a book? This forum is ONLY for asking specific queries.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Hello Friends
What is Difference between
ShowWindow(hwndDlg,SW_HIDE) and EndDialog(hwndDlg,0)?
Which One we need to use?
Thanks & Regards
Yogesh
|
|
|
|
|
ShowWindow(hwndDlg,SW_HIDE) only hides the window (but the window still exists) and furthermore, it can be applied to any type of window (even a control for instance). EndDialog destroys a modal dialog, so the dialog doesn't exist anymore afterwards. And it can only be used for a modal dialog (it would be a bit similar as calling OnOk or OnCancel).
yogeshs wrote: Which One we need to use?
That really depends on what you want to do . If you need to use only one of the functions, why would both of them exist ? They are there for a purpose and both of them can be used depending on the purpose.
|
|
|
|
|
Usually documentation helps.
For instance MSDN on EndDialog [^]:
The EndDialog function destroys a modal dialog box, causing the system to end any processing for the dialog box.
MSDN on ShowWindow [^]:
The ShowWindow function sets the specified window's show state.
Hence, roughly speaking, the former destroys the window, the latter just hides it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
c++ program to convert text into braille character
|
|
|
|
|
You just asked this same nonquestion a half an hour ago. #1 you didn't ask a question. #2 you're not likely to just be handed a program.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Please understand that, no one can help you by giving the whole source code.
Its better to ask, either as
"Any one have idea, how to convert a plain text into braille character programmatically. Using c or c++, Any help will be appreciated."
Well please go through Libbraille, the following link [^].
It will surely help you.
Величие не Бога может быть недооценена.
modified on Friday, December 11, 2009 1:23 AM
|
|
|
|
|
Surely a simple array is most of what's needed (maps from characters to strings, say).
Steve
|
|
|
|
|
moinsheikh wrote: c++ program to convert text into braille character
That's a bold statement.
|
|
|
|
|
c++ program to convert text into braille character
|
|
|
|
|
Please go through the instructions about how to ask a question [^].
Величие не Бога может быть недооценена.
|
|
|
|
|
Besides the fact that this is a terribly worded question (was there a question at all in your post?) you don't even need to write a program to convert text to braille. Simply download a braille font and make the text use that font.
If you absolutely think it's necessary to write a program to do this, then look at the section "Unicode rendering table" in the wikipedia article on braille.
|
|
|
|
|
|
below is C++ code
jmethodID mid;j
class cls = env->FindClass( "test/MyTest");
mid = env->GetMethodID(cls, "append","(Ljava/lang/String;I)Ljava/lang/String;");
mid=env->GetMethodID(cls,"HelloWord","()Ljava/lang/String;");
below is display by javap
public test.MyTest(java.lang.String);
Signature: (Ljava/lang/String;)V
public java.lang.String HelloWord();
Signature: ()Ljava/lang/String;
public java.lang.String append(java.lang.String, int);
Signature: (Ljava/lang/String;I)Ljava/lang/String;
below is java code:
public String HelloWord()
{ System.out.println("JAVA-CLASS:MyTest method:HelloWord:" +helloword);
return helloword;}
public String append(String str, int i) { return str + i; }
notice: the class has been found successfully, and the construct function <init> 's id is not return 0
question:why the other methods’s id always return 0??
|
|
|
|