mfc >> Help Required Regarding Threads

by Deepak » Mon, 24 Nov 2003 19:42:45 GMT

Hello,

I am executing one small task of drawing on a picture control inside a
thread function.

The drawing takes approximately of around 630 milli seconds to complete the
whole task.

I have placed three picture controls and I am starting 3 threads using
CreateThread API.

Also I have given a sleep inside Threadfunction of 1000 milli sec.

When I execute this (start thread) I can only see that, the first 2 picture
controls get updated and 3 rd
picture control is not getting updated (remains in state of original
position without graph moving).
But when I stop the threads then suddenly the third 3 rd picture control
also gets updated to exactly to the same position of the 1 and 2 nd
controls.

Why is this happening like this, is there a solution to over come this
problem?
should I avoid giving sleep of 1000 milli sec inside thread?

Thanks for reply

Deepak





Similar Threads

1. Help Required Regarding Threads

Hello,

I am executing one small task of drawing on a picture control inside a
thread function.

The drawing takes approximately of around 630 milli seconds to complete the
whole task.

I have placed three picture controls and I am starting 3 threads using
CreateThread API.

Also I have given a sleep inside Threadfunction of 1000 milli sec.

When I execute this (start thread) I can only see that, the first 2 picture
controls get updated and 3 rd
picture control is not getting updated (remains in state of original
position without graph moving).
But when I stop the threads then suddenly the third 3 rd picture control
also gets updated to exactly to the same position of the 1 and 2 nd
controls.

Why is this happening like this, is there a solution to over come this
problem?
should I avoid giving sleep of 1000 milli sec inside thread?

Thanks for reply

Deepak








2. Help required regarding AxMSChart - CSharp/C#

3. help regarding Threading

Hi all
i am having application in C#.
here what i want it to update one datagrid depending on particular
value.
I want to start minimum of 5 threads at a time and all these threads
are updating datagrid in their thread proceudre.
What i want is whenever 5 threads are running as soon as one thread
finish its execution i want to asssing new thread proceudre to that
thread.
Can some one tell me how to do it?
Any help will be appreciated.
thanks in advance.

4. Help regarding thread procedure. - CSharp/C#

5. Question regarding drawing in thread and main thread.


I have a question I was hoping to get help with.

I'm working on a multi-threaded app,  everything is working fine but I'm 
concerned I might be doing things wrong, asking for trouble.

The question at hand is getting a DC and drawing in both the main thread and 
the secondary thread.

In my drawing thread I get a DC  via a call to PageView->GetDC where 
PageView is a clasas that inherits from  CScrollView.  I make this call each 
time before I draw.

In the main thread I mostly draw into an offscreen bitmap, and then blit to 
a DC gotten in a similar method from the main thread.

I do use syncrhonization for my thread draw code, it is thread safe  draws 
to an offscreen bitmap and blits to the DC.

The thing that has me concerned is I read that the Non -MFC  GetDC(hwnd) 
returns a DC that should not be used in different threads.  I checked the 
help for the CWnd::GetDC() and nothing was mentioned.   Is it okay to use the 
CWnd:GetDC in each thread for drawing?

As an added piece of information I printed out the m_hDC for each thread 
during execution.  They never seemed to use the same one but swap numbers 
occasionally.

For example

Drawing Thread     Main Thread

251589022          939454949
251589022          939454949
251589022          939454949
then would switch 
939454949          251589022          
939454949          251589022 

Thanks much for any help!

James

6. HELP : regarding Textbox Enter and Focus Thanks guys and gals for all your help - CSharp/C#

7. A doubt regarding widgets and threads.

I have a doubt: is it dangerous to create widgets out of the main thread, or
it is dangerous to call methods of a widgets out of the thread which created
it? or both?

TIA
Perry


8. confusion regarding threading - CSharp/C#