|
I will give it a try and let you know how it works. Thanks.
|
|
|
|
|
Thank you, I have been doing some reading on samples that people have posted using this and I have found some other articles as well. This looks like what I needed.
|
|
|
|
|
I have worked with a couple samples in trying to figure out the best practices of multithreading applications. Most of these samples use threads that are only ran for short periods of times. What I would like to do is write a program that spawns off 4 threads. These 4 threads stay dormant or suspended until I send them a file to work with. Then they become active and go to work. When they are done, they should report back to the main application thread.
Where should I start looking for information on how to do this? Does anyone know of a good book that has good samples on how to do this? Do you know of an example on here that works this way?
Thanks
|
|
|
|
|
I created a project: HomeWork with a document-view.
This is a static function:
Header:
static DWORD __stdcall Thread(LPVOID lp);
Implementation:
DWORD __stdcall CHomeWorkView::Thread(LPVOID lp)
{
CHomeWorkView* parent = (CHomeWorkView*)lp;
parent->Work();
return 0;
}
A member variable is also there:
HANDLE m_hEvent;
A public member function of the class:
Header:
void Work();
Implementation:
void CHomeWorkView::Work()
{
while (TRUE)
{
if (WaitForSingleObject(m_hEvent,INFINITE) == WAIT_OBJECT_0)
{
MessageBox("Working on the file right now");
}
}
}
OnBtnStart:
DWORD id;
m_hEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
CreateThread(NULL,0,Thread,this,0,&id);
When you want to start the work:
PulseEvent(m_hEvent);
------------------------
This is this's style of working with worker threads, kinda.
Just make it four threads, like Thread1, 2, 3, 4 etc. and four worker funcs like Work1, 2, 3, 4.
If you don't like this's style, then look somewhere else.
this is this.
|
|
|
|
|
This[^] article will be of great help...
Behind every greak black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
This concept is called as Thread Pooling, Here[^]is a good article from MSDN. Have a look.
<bold>- Nilesh
<italics>
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Thank you all for the good info. I have a lot to read. Just so everyone knows what I would like to build I will say it here. I want to make my own emailing program for SMTP testing. I know there are many out there but I have to send very specific type of emails in the .eml format. I have a very good program that already works exactly like I want but it runs on a single thread. I figured it would be a good challenge to make it multithreading. But if I choose to run 5 threads I want the application to start the 5 threads and then send task to each of the threads rather than all 5 just doing a predetermined task. I want to be able to send a command like send c:\test1.eml or send c:\test2.eml etc. Then the thread should report back when it is done and ready for the next command. This sounds more challengig to pull off and I can learn more by this method if I get it working right.
Thank you.
|
|
|
|
|
Does anyone know the keystrokes to turn on wrap in the VC++ 6 ide?
|
|
|
|
|
|
Tools | Options | Text Editor | C/C++. Then (un)check the "Word wrap" box.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
That works in VS7, OP asked for VC6. AFAIK there is no word wrap option in VC6.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Ugh, you're right. Note to self: do not post replies before executing bootstrap caffeination.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
hi there,wonderful guys.
i think i have to commend everyone in this judicious forum for doing a nice and pleasing job.
hello,is there any body in this forum who could assist me to use vc++ in writing program on clock which will be functioning exactly the way clock work.
pls i need respond to this question on time for the completion of a project i have at hand now,
you can as well email me for my better understanding.
thanks.
prince_kolly@yahoo.com
|
|
|
|
|
princekolly wrote:
hello,is there any body in this forum who could assist me to use vc++ in writing program on clock
Yes, several.
princekolly wrote:
pls i need respond to this question on time for the completion of a project i have at hand now,
Smells like homework. Please elaborate.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Do you want to create a Digital clock or Analog clock?
For Analog, you need to do some mathematics. HeHe. Now you are stuck!
this is this.
|
|
|
|
|
khan++ wrote:
Do you want to create a Digital clock or Analog clock?
Neither. I've no desire for a clock.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
DavidCrow wrote:
Smells like homework. Please elaborate.
Why did I have the image of a baddie in a film smiling slowly as he turns to the next victim ?
British of course, british actors make much better baddies than american actors.
The tigress is here
|
|
|
|
|
princekolly wrote:
writing program on clock
How much have you coded till NOW?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
|
I don't think you're going to get much help with an "email me for better understanding" post. This forum is not meant for people to do other's work. Rather we help people who are facing specific problems that they've defined during their development.
Do you have a specific question or are you looking for someone to basically write your application for you?
|
|
|
|
|
Is there a way to access things like my video capture card without directx?
|
|
|
|
|
|
Im outputing some simple text to a view using CScrollView and i encountered something that I found to be very odd. When I use this code control the size of the scrollbars it cuts off some of the text.
CRAWConversionScrollDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
<br />
CRect rTextSize;<br />
rTextSize.SetRect( 0, 0, 800, 1200 );
this->GetDC()->DrawText( *(pDoc->GetConvertedData()), &rTextSize, DT_LEFT | DT_EXPANDTABS | DT_CALCRECT );<br />
<br />
CSize sizeTotal;<br />
sizeTotal.cx = rTextSize.Width();<br />
sizeTotal.cy = rTextSize.Height(); <br />
CScrollView::SetScrollSizes(MM_TEXT, sizeTotal);
however when I modify the code to proportionaly resize the scrollbars like so it works just fine
CRAWConversionScrollDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
<br />
CRect rTextSize;<br />
rTextSize.SetRect( 0, 0, 800, 1200 );
this->GetDC()->DrawText( *(pDoc->GetConvertedData()), &rTextSize, DT_LEFT | DT_EXPANDTABS | DT_CALCRECT );<br />
<br />
CSize sizeTotal;<br />
sizeTotal.cx = rTextSize.Width() + ((double)rTextSize.Width()/1.6);<br />
sizeTotal.cy = rTextSize.Height() + (rTextSize.Height()/8);<br />
<br />
CScrollView::SetScrollSizes(MM_TEXT, sizeTotal)<code><br />
<br />
What im wondering is the reason for this behavior. With the modified code my text comes out properly regrardless of how much text there is be it 1 page or 50+ pages.<br />
<br />
Any help with this would be appreciated<br />
-thx
|
|
|
|
|
The code you posted will measure the text based on the default font. Are you using a different font when drawing the text?
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Yes I am using a different font, I guess I will just change the font before I measure, thx for the help
|
|
|
|