Problem with blocking of main thread with other thread
I have a problem with blocking of main thread:
My application contains an interpreter and I need to write a debugger
The mainframe creates a thread that is interpreting instructions. When I
need to break execution of instruction thread, I use
in the interpreter thread.
Everything works fine until the window is opened from the interpreter.
Then the mainframe freezes.
When I break execution in VC the call stack for interpreter thread shows:
� _Afx...Where is my thread?
I posted a question about "Search for a value in multi-dimensionla array" an
hour ago; where did that go?
On 5/17/2010 17:38, Rick wrote:
> I posted a question about "Search for a value in multi-dimensionla array" an
> hour ago; where did that go?
If you mean the one beginning with "Seach", posted almost half an hour
before this one, it is there. :)
On 5/17/2010 11:51 AM, Jackie wrote:
> On 5/17/2010 17:38, Rick wrote:
>> I posted a question about "Search for a value in multi-dimensionla
>> array" an
>> hour ag...Diaglog/Threading Data Exchange Question
I have learned a lot from all of you, and I hope to over come my latest road
block. I have a smal IRC Chat client I am making.
I have a Dialog Box with Control and I use a worker thread for connecting to
IRC - That Thread will update controls on the Dialog by sending
Now my problem is in the ListBox Control that I have extended to do popup
menu with various commands.
I need to be able to read that controls methods from within the Thread.
so I need to do this from within my IRC Socket thread:
(code not exact - pseudo code)
CListBoxEx myUsers; //Defined in my ...Need Help with Busy Dialog Thread
my application would perform a task. I want to stop the user from using the
application's GUI untill the the BG task is finished.
At first using Modal Dlg did not do the trick as every one now (apart from
me) the the CDialog::DoModal() function has to return some how.
I made a bit of research on the net and found a trick to display the Dialog
using CWinThread derived class without stoping the main app window for
executing the background task as follows:
(1) In your header file define a CWinThread-derived class...
class CDialogThread : public CWinThread
DECLARE_DYNCREATE(CDial...Killing thread from outside thread in MFC App
Thanks to all those who offered advise on my last query. I successfully used
the worker thread method to give control back to the dialog box whilst
background processing was being carried out.
The issue I have now is closing that thread externally. The method I've used
to create the thread uses a volatile boolean variable. Whilever it is set to
TRUE, the thread remains alive. However, when I set the variable to FALSE
from the calling process (user wants to end processing), it has no effect.
The thread continues to run.
I thought that declaring the variable as 'volatile'...Simple Thread
I have created a thread in my MFC Dialog based application, in the thread
function i want to have access to a user interface control that is attached
to the main dialog.
How can I do it?
> I have created a thread in my MFC Dialog based application, in the thread
> function i want to have access to a user interface control that is attached
> to the main dialog.
> How can I do it?
Indirectly, by posting a message to the main thread asking it to update
the control. http://www.mvps.org/vcfaq/mfc/12.ht...To Thread or not to thread
I am using a CRecordset object to retrieve data from a remote server. The
time to retrieve the data is highly variable because of network traffic etc
etc etc and has varied from a few ms to almost a minute.
Is it a good practice to use a worker thread to handle the database
exchange to avoid having my main thread block for long periods of time? I
assume that I would let the exchange timeout and then check the return
status and a global variable to determine if it should keep trying until it
returned data ( might be null but that's ok).
While it may be a tin...Anyone care to offer advice for my Client / Server threading model
I'm a bit of a sockets newbie and not too sure what the established
ways of handling CAsyncSockets are.
I need to handle two way comms between two or more handheld pcs and a
WIth the server I've got:
1 Thread polling for new connections
1 Thread per client connection.
The client thread is stuck in a loop called from
CWinThread::InitInstance and sits and calls the CAsyncSocket::Receive
function until something arrives. It uses peekmessage and postmessage
in this loop to see if the app wants me to send anything to the client.
This is working erratically though - peekmessage know...multi-threaded control not destroyed on exiting the page?
I have created an ActiveX control (subclassing COleControl) which uses
the afxRegFreeThreading model, and I have a small sample web page which
inserts the control using an <object> tag. I noticed that when my page
places the control inside the <head> tag, the control's destructor is
called when my browser goes to a different page. But if the control is
inside the <body> tag, the destructor is not called when I leave the
page. The control's destructor is eventually called when I exit my
browser, but I fear that my control is continuing to occupy system
resources unt...Threads in MFC
Hi to all...
I've made a multithreaded Application (with MFC of course) and it works well
on some PC, but in others PC's with the same OS (Win2000SP4)
it throws "access Violation" immediatly just when a thread starts. (No
matter which one... just the first).
I've supposed it was some lib missing, and I've installed VC6... it didn't
I had a similar problem when I didn't realize I was trying to distribute a
DEBUG version of the program. Otherwise, can you post a code snippet?
On Mon, 19 Apr 2004 16:55:16 +0200, Nicola Bam...MAD monitoring thread?
I have Exchange 2000 running on a Win2K Server. I have a trust to an NT4
domain with an Exchange 5.5 Server. Both are in the same site and my goal
is to move the mailboxes and whatnot to the Exchange 2000 box.
So far, just getting 2000 to operate has been a problem. It's installed and
running but my MS Exchange Info Store and MTA stacks won't start in the
services. If I reboot, they start, but stop within a few minutes. I have
errors in my application log for MSExchangeSA that say, "The MAD monitoring
thread was unable to read its configuration from the DS."
I have MSEx...A thread within a thread...
If i create a thread within a thread, something like...
void threadA(void lparam )
// do more work
My question is what happens to the thread i created, (threadB), if it is not
Is it safe, good?, to stop threadA without waiting for threadB.
There is no concept of "a thread within a thread". All threads are within a process, and
they are all peers of each other.
DO NOT use _beginthread in an MFC program. This is asking for trouble. An...why CStatic.m_hWnd not valid use realtime thread
I build an MFC app, and loadlibrary a dll which use high priority (realtime level ) threads for serial communication
but after freelibrary the dll, some CStatic and CEdit objects not valid, their m_hWnd becomes to NULL
How can I restore these CWnd objects? Is OS release them
thanks, waiting online
I have a server/client application that communicates using threads. The
server class uses a while loop inside a thread to wait for new connections
in accept state, like this:
var a = new var( );
while( (server.Accept(connection)) )
I have declared a variable (var) right before this loop which uses memory.
I want to free/delete this variable at the end of the while loop, but the
control never reaches there.
How can I make sure that this variable gets deleted before the server side
Jessica Weiner wrote:
> I have a server/client applicatio...Destroy thread and Terminate thread
is there any difference between
"Destroy thread and Terminate thread"
"Vinay" <firstname.lastname@example.org> wrote in message
> is there any difference between
> "Destroy thread and Terminate thread"
A quote from the docs: "TerminateThread is a dangerous function that should
only be used in the most extreme cases." destroyThread, on the other hand,
deletes the thread object created by createThread. The thread should be
terminated by some o...Start background thread when a UI button is clicked, and Update UI button from background thread
I was asked these questions during a technical interview:
1) When the user clicks on a button on the form and that invokes a lot
of heavy-duty calculations, what would you do?
I would use "BeginInvoke" to start a background worker thread to do
the heavy-duty calculations, in order to avoid blocking the main UI
Then he asked, "What does 'BeginInvoke' do"? I said it was a .NET
pattern to start a background thread from a UI thread. Did I get it
2) Why can't you simply update a button on the UI thread from a
background ...Message Threads
Is there a way to organize a mail folder so that messages are organized
similar to newsgroups? Based on whether or not the message is a reply?
Thanks in advance for your help
(Outlook 2003 in Windows XP Pro)
Have you tried the Arrange By Conversation view?
MVP - Outlook
*** Messages sent to my e-mail address will NOT be answered -- please
reply only to the newsgroup to preserve the message thread. ***
> Is there a way to organize a mail folder so that messages are
> organized similar to news...how to get thread view in newsgroups?
I used to access newsgroups via Outlook Express where all messages within
newsgroups were grouped in their threads with a collapse/expand plus or
minus sign which was convenient and intuitive. Each one would indent
according to which previous message was answered.
Having moved to Windows Live Mail and accessing my newsgroups via this prog.
now, I don't seem to be able to find the same kind of display option. All
messages display independently in date order, and I can't find a way to
group them in their normal thread except by entering something from the
thread in the ...My Threads
I just cant seem to figure out how to see all my postings since i started how
do i see my own only thanks
On Thu, 29 Apr 2010 11:27:01 -0700, Amin <Amin@discussions.microsoft.com>
>I just cant seem to figure out how to see all my postings since i started how
>do i see my own only thanks
The Search function on the Microsoft webpage is broken; I've never been able
to get it to work.
What you can do instead is use a competitor's product:
http://groups.google.com. Use Advanced Search to search for your posts, e.g.
searching for email@example.com...Thread Pool Class?
Can anyone recommend a good thread pool class?
"Don Gurr" <dongurr@REMOVEshaw.ca> ha scritto nel messaggio
> Can anyone recommend a good thread pool class?
Have you tried CThreadPool from ATL (I believe it can be used in MFC code as
Thanks, it appears to work.
"Giovanni Dicanio" <giovanniDOTdicanio@REMOVEMEgmail.com> wrote in message
> "Don Gurr"...Off group subject but...how do MVPs follow threads ?s
I've been curious as to how a MVPs (or others with many posts and
replies) keeps track of posts/threads?
Do you download all threads?
Or leave online and let your "newsreader" maintain all history?
I've always done the former. I manage all newsgroup activity in my mail
program. I send a copy of my posts to myself and redirect a copy of all
replies. I often, well sometimes ;), access those archived posts but it
is somewhat time consuming process and I'm interested if there are more
I've posted similar questions to t...how to end a thread from the main thread
how to end a thread from the main thread
> how to end a thread from the main thread
Ending a thread directly from another thread should always be
considered not an option.
If you want to end a UI thread, post a WM_CLOSE message to it and let
it terminate itself.
If you want to end a worker thread, use a variable to signal to the
thread that it's time to shut down.
If you need to wait until the thread is shutdown, wait on it's handle
in the main thread.
Which type of thread are you using?
See my essay on worker threads on...problem with starting thread
During debugging if we go over the following line of code:
m_pCalculateThread = AfxBeginThread(UpdateDocThread, this);
the thread DOES NOT start, but if we go into AfxBeginThread function,
the thread DOES start. Any suggestions?
Thanks in advance!
Maybe you can look in the threads window during the debug. You could set
execution to a thread using that too.
"Leonid Nikolayev" <firstname.lastname@example.org> wrote in message
> During debugging if we go over the following line of code:
> m_pCalculateThread = AfxBeginThread(Upd...Worker threads acces to main dialog
Is it safe to pass a pointer to my main dialog app to worker threads and
then have them call member functions like GetDlgItem etc?
I will, of course, protect these calls with CCriticalSection.
"dwizard" <email@example.com> wrote in message
> Is it safe to pass a pointer to my main dialog app to worker threads and
> then have them call member functions like GetDlgItem etc?
> I will, of course, protect these calls with CCriticalSection.
No, only the thread that created a window shoul...SendMessage for threads
This is not really an MFC question, and for that I apologize, but I am
programming in MFC and I can't seem to find a better newsgroup to post this
Is there an equivilant functionality to SendMessage for a thread? I am
using PostThreadMessage, but is there no way to specify that I want the
calling thread to block until the thread being messaged has completed the
task... just the same way that SendMessage does for windows? Or would that
have to be implemented per thread implementation with syncronization objects?
It sure would be nice if there were a gene...