473,383 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Running a function in the background

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.

Mar 26 '07 #1
4 2971
On 26 Mar, 08:10, "ADT_CLONE" <spell_d...@hotmail.comwrote:
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

Mar 26 '07 #2
On 26 Mrz., 08:20, "Erik Wikström" <eri...@student.chalmers.sewrote:
On 26 Mar, 08:10, "ADT_CLONE" <spell_d...@hotmail.comwrote:
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.

Mar 26 '07 #3
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.

Mar 26 '07 #4
On Mar 26, 7:44 pm, "exylum" <exy...@gmail.comwrote:
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.

Mar 26 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Arun | last post by:
Hi, This is a scripting question, but since I am writing the script in python I am posting this question here: I have a python script that runs a simulator (that was written in c++, so I use...
4
by: Si | last post by:
Hi Guys I am using this code to execute an Access VBA function from ASP: strDbName = strDataSource & "data\webjobs.mdb" Set objAccess = Server.CreateObject("Access.Application")...
29
by: pb648174 | last post by:
I have a very long transaction that runs on the same database that other users need to use for existing data. I don't care if they see data from the transaction before it is done and am only using...
5
by: Ben Dewey | last post by:
This is a repost, But I have some new information. I have a server that is configured for .NET 1.1 and 2.0. For some reason all my postback events for aren't firing when using .NET 1.1. Under...
1
by: Anonieko | last post by:
Query: How to display progress bar for long running page Answer: Yet another solution. REFERENCE: http://www.eggheadcafe.com/articles/20050108.asp My only regret is that when click the...
2
by: Dave Hughes | last post by:
Just noticed something rather annoying after upgrading my test box (a Linux server running DB2 UDB v8 for LUW) to fixpak 11 (for reference it was previously on fixpak 7). In the past I've relied...
9
by: esakal | last post by:
Hello, I'm programming an application based on CAB infrastructure in the client side (c# .net 2005) Since my application must be sequencally, i wrote all the code in the UI thread. my...
6
by: ADT_CLONE | last post by:
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...
3
by: nathanwb | last post by:
I have the following php code, at the top I am pulling a piece of data from a query and I echo the results with no problem, I am using Ajax with this page as well and further down the page when I...
13
by: Andrew Falanga | last post by:
HI, Just a warning, I'm a javascript neophyte. I'm writing a function to validate the contents of a form on a web page I'm developing. Since I'm a neophyte, this function is quite simple at...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.