Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Running a function in the background

Reply
Thread Tools

Running a function in the background

 
 
ADT_CLONE
Guest
Posts: n/a
 
      03-26-2007
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.

 
Reply With Quote
 
 
 
 
=?iso-8859-1?q?Erik_Wikstr=F6m?=
Guest
Posts: n/a
 
      03-26-2007
On 26 Mar, 08:10, "ADT_CLONE" <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
 
Alexander Block
Guest
Posts: n/a
 
      03-26-2007
On 26 Mrz., 08:20, "Erik Wikström" <(E-Mail Removed)> wrote:
> On 26 Mar, 08:10, "ADT_CLONE" <(E-Mail Removed)> 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.

 
Reply With Quote
 
exylum
Guest
Posts: n/a
 
      03-26-2007
also check the winapi settimer function:
http://msdn.microsoft.com/library/de...s/settimer.asp

although i think that the asynchronous mode posted by
Alexander Block is the best way.

 
Reply With Quote
 
ADT_CLONE
Guest
Posts: n/a
 
      03-26-2007
On Mar 26, 7:44 pm, "exylum" <(E-Mail Removed)> wrote:
> also check the winapi settimer function:http://msdn.microsoft.com/library/de...ary/en-us/winu...
>
> although i think that the asynchronous mode posted by
> Alexander Block is the best way.



Thanks guys, I'll look through these.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DIV background-repeat background-image? For shadow effect jc ASP .Net 3 03-19-2008 04:19 PM
DIV background-repeat background-image for shadowing effect jc HTML 1 03-19-2008 02:16 PM
not able to click on background tab and backgrounds in properties to change the background. rex Computer Support 2 12-06-2006 02:26 AM
Background transparent when 'background' is used JWL HTML 4 09-26-2006 05:37 PM
Background Check - Background search - People search mason66 ASP .Net 0 07-27-2006 10:20 AM



Advertisments