exit while loop when button clicked

This is a discussion on exit while loop when button clicked within the Windows Programming forums, part of the Platform Specific Boards category; I want to do, but don't know how in MFC...

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    15
    I want to do, but don't know how in MFC

  2. #17
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    As I said before, if you are sitting in a busy loop or on a blocking function call, your windows loop will not be able to receive and process the message associated with the button press. This will be the case in MFC as well as regular Win32 programming.

    If Windows cannot process the message, it cannot act on it. Thus, your UI is unresponsive. That is why the design is poor. I would have the blocking calls/busy loops in another thread, leaving the UI in the main thread, and active at all times.

    This is a classic case where threading is useful.

    Threading is not inherently difficult, (I have a simple introductory tutorial on my site, here), but be aware that MFC had it's own threading support classes.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #18
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Look at CSocket and CAsyncSocket.

    The socket will listen automatically and notify your app when data events happen ie incomming data == OnReceive().
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #19
    Registered User
    Join Date
    Jan 2005
    Posts
    15
    Does anyone know of a simple tutorial/book on how to creat multi-thread in MFC?

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My BS_OWNERDRAW button draw as white when clicked...
    By Jonathan Beaubi in forum Windows Programming
    Replies: 1
    Last Post: 08-16-2007, 10:41 AM
  2. loop the loop - feeling foolish
    By estos in forum C Programming
    Replies: 2
    Last Post: 04-07-2007, 02:45 AM
  3. Stopping an Infinite Loop
    By linuxpyro in forum C Programming
    Replies: 4
    Last Post: 11-30-2006, 11:21 AM
  4. Replies: 1
    Last Post: 10-27-2006, 01:21 PM
  5. I can't figure out why this doesn't exit the loop, MAN!
    By Shadow12345 in forum C++ Programming
    Replies: 2
    Last Post: 10-02-2002, 08:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21