|
Nelek wrote: mmmm, maybe yes...
he he he what about OutputDebugString
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You have a default constructor for CPrintPreviewState in two .cpp files. Why?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello Friends,
Is there any way we can make the main thread sleep from within the another user created theread.
I am using the code like below
void fun(void)
{
...
...
if(Some Condition)
{
CreateThread(0, 0, ( LPTHREAD_START_ROUTINE ) ThreadProc, 0, 0, 0 );
DialogBox(...);
}
if (Some Other condition)
{
}
}
void ThreadProc(void)
{
fun();
}
-- modified at 6:01 Wednesday 17th October, 2007
|
|
|
|
|
GauranG33 wrote: from within the another user created theread
WTF are you trying to say here ?!
|
|
|
|
|
Now I hav modified the Question. and Put some Example code.
|
|
|
|
|
toxcct wrote: WTF are you trying to say here ?!
Don't Know [ ]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
that depends on the design and implementation of both of your threads.
and also, the context, where the sleep is required matters.
can you share them with us?
----------------------------------------------------------
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
it seems that, you are landing in some sort of recursion here.
BTW,
i understood that, you want to do some application, which keeps a dialog displayed until you stop it.
am i right?
if so, then i can guide you better.
|
|
|
|
|
actully I want to display the Dialog Box Continously untill some events happen and also want that my application run in the background and so i am using the thread.
|
|
|
|
|
thats what i meant.
i have one active X control made by me to achieve your task.
if you want, i can share it with u.
you have to use it as follows.
your main thread
{
control.start();
//your code which u call as ur background code here
........
........
//control.stop();
}
here, from ur start to stop function, the dialog will be displayed.
|
|
|
|
|
Have the main thread create and display a modeless dialog box. This way the box is displayed but the main thread can keep working.
Judy
|
|
|
|
|
GauranG33 wrote: actully I want to display the Dialog Box Continously untill some events happen and also want that my application run in the background and so i am using the thread.
call a model dialog box.. it block the main thread, and you thread will continue to run in background
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
yes it displays the modeless dialog
|
|
|
|
|
That wasn't what I meant. I was addressing your statement from the initial post:
CreateThread(0, 0, ( LPTHREAD_START_ROUTINE ) ThreadProc, 0, 0, 0 );
//I want to show some dialog continuously and also the same function (fun) to be running.
//And So I am using the Thread to call the Function (fun() )
DialogBox(...); //
To accomplish this, consider displaying a modeless dialog box and just directly calling the function. This may not be appropriate for your program - it depends on what the function actually does, but you didn't provide enough information.
Judy
|
|
|
|
|
do you exactly want some dialog, that displays something like,
"Some task is going on Please Wait......".
|
|
|
|
|
then display model dialog.. is there is any problem..
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Why you want to make Main Thread Sleep..? this is not good design. as in Sleep State main thread will process nothing. you should change you design to make MianThread do nothing instead of making it sleep.
GauranG33 wrote: void ThreadProc(void){ fun();}
this will make your worker thread sleep not main thread. as function call is from worker thread not main thread
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
GauranG33 wrote: //Here I want the main thread to sleep for some time
Bad idea.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i have made a user interface thread and started it using this code
<br />
NetConnect = (CNetConnect*)AfxBeginThread( RUNTIME_CLASS(CNetConnect),<br />
THREAD_PRIORITY_NORMAL,<br />
NULL,<br />
CREATE_SUSPENDED,<br />
NULL);<br />
<br />
NetConnect->ResumeThread();<br />
Now i want to terminate/End this thread. I have tried using
<br />
NetConnect->PostThreadMessage(WM_QUIT,NULL,NULL);<br />
but the thread is still running. How to do end this thread?
Thakns in advance
|
|
|
|
|
seems to be solvable, but not clear.
can you put your post in some other way?
|
|
|
|
|
neha.agarwal27 wrote: Now i want to terminate/End this thread. I have tried using
NetConnect->PostThreadMessage(WM_QUIT,NULL,NULL);
please check.. is the thread is busy with something!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
what happens if you use of ExitThread ?
|
|
|
|
|
Hamid. wrote: if you use of ExitThread?
ExitThread doesn't work well with the UserInterface thread. usually you have to use post quit message.
Hamid. wrote: Hamid.
I like your previous name i.e. [WhiteSky]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I must say I like that name but I think maybe its better I use of my name instead nickname.;)
|
|
|
|
|
What are you doing in CNetConnect::Run() ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|