Running a function in the background

A

ADT_CLONE

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.
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

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.
 
A

Alexander Block

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.

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top