Running a function in the background

Discussion in 'C++' started by ADT_CLONE, Mar 26, 2007.

  1. ADT_CLONE

    ADT_CLONE Guest

    Hello guys,

    Right now I have run into a problem. In my windows application I wish
    to run a function called waitForClient(), which waits for a clients
    connection using WinSock. Anyway, within the button click event, I
    have inserted this function. The only problem is that when you click
    the button, it freezes the whole windows application. This is because
    it is running an infinite loop and isn't properly running the rest of
    the button code.

    What I was wondering was if there was anyway to run a function in the
    background. I'm looking for an easy way out of this, though if I have
    to I will use threads. Thanks in advance.
    ADT_CLONE, Mar 26, 2007
    #1
    1. Advertising

  2. On 26 Mar, 08:10, "ADT_CLONE" <> wrote:
    > Hello guys,
    >
    > Right now I have run into a problem. In my windows application I wish
    > to run a function called waitForClient(), which waits for a clients
    > connection using WinSock. Anyway, within the button click event, I
    > have inserted this function. The only problem is that when you click
    > the button, it freezes the whole windows application. This is because
    > it is running an infinite loop and isn't properly running the rest of
    > the button code.
    >
    > What I was wondering was if there was anyway to run a function in the
    > background. I'm looking for an easy way out of this, though if I have
    > to I will use threads. Thanks in advance.


    Threads is the (only?) way to go. Ask again in
    microsoft.public.dotnet.languages.vc and they will be able to help you
    with that. Perhaps they can also tell you a way to avoid using a loop
    in waitForClient() if you describe what it does.

    --
    Erik Wikström
    =?iso-8859-1?q?Erik_Wikstr=F6m?=, Mar 26, 2007
    #2
    1. Advertising

  3. On 26 Mrz., 08:20, "Erik Wikström" <> wrote:
    > On 26 Mar, 08:10, "ADT_CLONE" <> wrote:
    >
    > > Hello guys,

    >
    > > Right now I have run into a problem. In my windows application I wish
    > > to run a function called waitForClient(), which waits for a clients
    > > connection using WinSock. Anyway, within the button click event, I
    > > have inserted this function. The only problem is that when you click
    > > the button, it freezes the whole windows application. This is because
    > > it is running an infinite loop and isn't properly running the rest of
    > > the button code.

    >
    > > What I was wondering was if there was anyway to run a function in the
    > > background. I'm looking for an easy way out of this, though if I have
    > > to I will use threads. Thanks in advance.

    >
    > Threads is the (only?) way to go. Ask again in
    > microsoft.public.dotnet.languages.vc and they will be able to help you
    > with that. Perhaps they can also tell you a way to avoid using a loop
    > in waitForClient() if you describe what it does.
    >
    > --
    > Erik Wikström


    There's also a way to handle sockets in asynchronous mode. You should
    read through the MSDN documentation to find out how to use them on
    Windows. Look for WSAAsyncSelect, which sends Windows messages to your
    application has pending incoming data or connections.
    Alexander Block, Mar 26, 2007
    #3
  4. ADT_CLONE

    exylum Guest

    exylum, Mar 26, 2007
    #4
  5. ADT_CLONE

    ADT_CLONE Guest

    ADT_CLONE, Mar 26, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mason66
    Replies:
    0
    Views:
    421
    mason66
    Jul 27, 2006
  2. JWL
    Replies:
    4
    Views:
    583
    Michael Winter
    Sep 26, 2006
  3. jc
    Replies:
    3
    Views:
    1,726
  4. jc
    Replies:
    1
    Views:
    1,362
    Neredbojias
    Mar 19, 2008
  5. Dj Frenzy
    Replies:
    3
    Views:
    306
    Robert
    Feb 10, 2004
Loading...

Share This Page