473,883 Members | 2,961 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Asynchronous Programming

I'm trying to determine if I need to make my application multi-threaded, or
if it can be done with asynchronous programming. I realize that asynch calls
do create a new thread in the background, but when they come back, they
return to the thread that launched them, is that correct? If I go
multi-threaded, then I just need to spawn a new thread for each new
connection, right?

What I'm doing here is making a service that accepts connections via TCP,
does some stuff, and then returns a response. Would my best bet be to go
asych or multi-threaded? Any articles on either or both would be much
appreciated.

Thanks,
Steve
Nov 15 '05
48 5464
Inline ***

Willy.

"Chad Z. Hower aka Kudzu" <cp**@hower.org > wrote in message
news:Xn******** **********@127. 0.0.1...
"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in
news:Os******** ******@TK2MSFTN GP10.phx.gbl:
User space is 2GB (half of the 4GB process space) or 3GB on
"LargeAddressAw are" enabled systems (3GB switch), default stack space is
Aah yes. Sorry you are right on the 1M and 2G. Was late last night. ;)
1MB per OS thread, .NET doesn't expose a managed way to create threads


This is a shame. :(

*** Not realy, except for special cases where you know exactly how much
stack space will be required, but here I assume you will write your own CLR
host, just like asp.net does.
The default Stackspace can be changed using EDITBIN.EXE.


EditBin? You mean as in editing the .net framework?


*** No, the executable assembly, which is just a normal PE file.
So, editbin /stack:256000 YourAssembly.ex e will set the default reserved
stack size to 256Kb.
Now the problem here is that all threads will take the same value, a low
value may lead to stackoverflow exceptions being thrown, when set too high
its just a waste of virtual memory. So IMO it's better to leave the value at
1MB default.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Nov 15 '05 #41
"William Stacey [MVP]" <st***********@ mvps.org> wrote in
news:#S******** ******@TK2MSFTN GP10.phx.gbl:
Well I was thinking more in terms of being safe and not pushing things
util it crashes as we may not have perfect knowledge upfront of all the
mem issues and async delegates and other IO (disk, etc). If 1700 is
around max, then I would not feel real sure about pushing 1000 as that
gets close, and you may have other async stuff going on and the rest of


1000 is not close to 1700. :)

When my son is 10 - I wont be worried about him "almost" being 17. :)

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
Nov 15 '05 #42
"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in
news:ue******** ******@tk2msftn gp13.phx.gbl:
*** No, the executable assembly, which is just a normal PE file.
So, editbin /stack:256000 YourAssembly.ex e will set the default
reserved stack size to 256Kb.
Aah by setting the process one. Thats how its done pre XP too.
Now the problem here is that all threads will take the same value, a low
value may lead to stackoverflow exceptions being thrown, when set too
high its just a waste of virtual memory. So IMO it's better to leave the
value at 1MB default.


In XP you can set it per thread - and it works very nicely.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
Nov 15 '05 #43
inline ***
Willy.

"Chad Z. Hower aka Kudzu" <cp**@hower.org > wrote in message
news:Xn******** **********@127. 0.0.1...
"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in
news:ue******** ******@tk2msftn gp13.phx.gbl:
*** No, the executable assembly, which is just a normal PE file.
So, editbin /stack:256000 YourAssembly.ex e will set the default
reserved stack size to 256Kb.
Aah by setting the process one. Thats how its done pre XP too.

*** Yep.
Now the problem here is that all threads will take the same value, a low
value may lead to stackoverflow exceptions being thrown, when set too
high its just a waste of virtual memory. So IMO it's better to leave the
value at 1MB default.


In XP you can set it per thread - and it works very nicely.

*** Sure, but not from within .NET, unless you PInvoke or use MC++.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Nov 15 '05 #44
Ok wise guy. Then lets play "pick a number" then. What's your number?
Factor in some working space for your actual program data, etc. And factor
in some fudge factor so as not to always be bumping max. Seems when you
push the memory line, strange things seem to happen. So its not 1700 or
1699, or even 1698. However it is probably > 700 and less then 1700.

--
William Stacey, MVP

"Chad Z. Hower aka Kudzu" <cp**@hower.org > wrote in message
news:Xn******** **********@127. 0.0.1...
"William Stacey [MVP]" <st***********@ mvps.org> wrote in
news:#S******** ******@TK2MSFTN GP10.phx.gbl:
Well I was thinking more in terms of being safe and not pushing things
util it crashes as we may not have perfect knowledge upfront of all the
mem issues and async delegates and other IO (disk, etc). If 1700 is
around max, then I would not feel real sure about pushing 1000 as that
gets close, and you may have other async stuff going on and the rest of


1000 is not close to 1700. :)

When my son is 10 - I wont be worried about him "almost" being 17. :)

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"


Nov 15 '05 #45
Chad,
Indy 10 has an option to use fibers and IOCP. The cool thing is its all
hidden from the user and they can switch from threads + winsock to fibers +
IOCP without changing a single line of their code.

Are you still writing Delphi code or have you switched to C#?

Is Indy 10 written in C# or still in Delphi?

Dave
Nov 15 '05 #46
"William Stacey [MVP]" <st***********@ mvps.org> wrote in news:O7agEJ#
$D*******@TK2MS FTNGP10.phx.gbl :
Ok wise guy. Then lets play "pick a number" then. What's your number?
Factor in some working space for your actual program data, etc. And factor
in some fudge factor so as not to always be bumping max. Seems when you
push the memory line, strange things seem to happen. So its not 1700 or
1699, or even 1698. However it is probably > 700 and less then 1700.


1699 and so on yes - but you stated 1000 was almost 1700. Thats what I was
replying to.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
Nov 15 '05 #47
D. Yates <fo****@hotmail .com> wrote in
news:a9******** *************** *********@4ax.c om:
Are you still writing Delphi code or have you switched to C#?
Still Delphi. We use C# in our company for demos and some VS specific code,
otherwise still all Delphi. Only Delphi allows us with one source code base
to support Win32, .Net and Linux.
Is Indy 10 written in C# or still in Delphi?


Delphi. I think you underestimate the sheer size and volume of code in Indy
if you think it could be ported to C# so easily. :)
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
Nov 15 '05 #48
"William Stacey [MVP]" <st***********@ mvps.org> wrote in news:O7agEJ#
$D*******@TK2MS FTNGP10.phx.gbl :
Ok wise guy. Then lets play "pick a number" then. What's your number?
Factor in some working space for your actual program data, etc. And factor
in some fudge factor so as not to always be bumping max. Seems when you


Here is the quote BTW:
"If 1700 is around max, then I would not feel real sure about pushing 1000 as
that gets close,"

I dont dispute that 1000 may be too much in most situations - I simply
disputed this statement that 1000 is close to 17000.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
Nov 15 '05 #49

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

Similar topics

6
3490
by: ... | last post by:
Does anyone know a good tutorial on asynchronous programming in .net AsyncCallback And IASyncResult are driving me crazy. And the msdn documentation is not really helpful on this topic I appreciate any recommendation.
4
1572
by: Chris | last post by:
Hello, With asynchronous programming : Why does the callback-function (running in a worker thread) may not update the state of a control on the main-form ? The docs say that you must use a MethodInvoker instead as in following example :
9
8680
by: Michael Lindsey | last post by:
I need to write a server app to send images to client GUIs that are outside of the server's domain. The client will have the file system path to the image but can not access the file system. I am trying to decide if I should use remoting vs. writing a server that uses networkstreams. I have read that networkstreams\tcp programming should be faster than remoting and is a better choice for what I am doing but that it is difficult to code.
4
348
by: bernardpace | last post by:
Hi, I am trying to get more familiar with asynchronous programming. I was reading through the document found on the page: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpovrasynchronousprogrammingoverview.asp Now, I read that 'Always call EndInvoke after your asynchronous call completes'.
1
1559
by: Julian Hershel | last post by:
Reading about asynchronous programming (ms-help://MS.NETFrameworkSDK/cpguidenf/html/cpconasynchronousdesignpatterno verview.htm) I could not clarify some doubts. Hope you can help me. 1) Are asynchronous programming and multithreaded programming two different pictures? As I read the help topic above it is not clear to me if the design pattern opens a new thread or not to run the methods asynchronously. 2) One unique thread can run...
1
3178
by: org | last post by:
Hi, I'm developing a web service with should be used by an .NET CF2 client and an .NET 2.0 Windows client. I've tried to put all the connection logic into one class, which could be used in common from the mobile and the windows client. But this didn't work: The new .NET framework supports asynchronous web services with the "MethodnameCompleted+=new MethodNameEventHandler pattern, but the "old style" .NET 1 pattern used in the compact...
5
2308
by: Ryan Liu | last post by:
Hi, I read Microsoft SDK, ms-help://MS.NETFrameworkSDKv1.1/cpguidenf/html/cpovrasynchronousprogramming overview.htm there are 4 ways to call EndInvoke: The code in this topic demonstrates four common ways to use BeginInvoke and EndInvoke to make asynchronous calls. After calling BeginInvoke you can:
3
2105
by: =?Utf-8?B?bWs=?= | last post by:
Hi everyone, I need to refactor some of our processes using the asynchronous programming model. I have defined a couple of arrays of delegates to pipline the asynchronous invocations through different stages of execution. However I was wondering if there was any information available regarding the limitations of the asynchronous model, in particular maximum numbers of asynchronous elements, and limitations of multiple requests potentially...
3
1544
by: senfo | last post by:
I recently read an MSDN article by Jeff Prosise titled, Scalable Apps with Asynchronous Programming in ASP.NET (http://msdn.microsoft.com/msdnmag/issues/07/03/WickedCode/). In the article, Jeff discusses scaling problems that some users experience with ASP.NET applications. The problem, Jeff writes, isn't that ASP.NET isn't capable of scaling; but has more to do with ASP.NET applications that use threads inefficiently. In the article,...
2
1465
by: =?Utf-8?B?U3JpcmFtIE1hbGxhanlvc3VsYQ==?= | last post by:
Hi, I was going through the article (http://msdn.microsoft.com/msdnmag/issues/05/10/WickedCode/) regarding async programming in ASP.Net 2.0 but did not find much of an use with it. Actually my requirement is that once a user logs in I need to call a web service which will perform some activity but I am not bothered with the result of the web service. I have a process.aspx which is called after login and after implementing the code...
0
11154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10762
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10422
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7977
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5807
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6005
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4622
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.