473,405 Members | 2,187 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,405 software developers and data experts.

IAsyncResult question

I don't actually have a need to do this right now but was wondering... I
also assume the answer to this is going to be no but....

thread 1 calls an async socket.beginReceive() method which returns an
IAsyncResult. So at that moment thread 1 has this IAsyncResult. If the
callback method for that beginReceive calls beginReceive again, will thread
1's IAsyncResult reference from that first beginxxx call now reference the
second call, and so on? I assume no, it would produce a new IAsyncResult
object for each new beginxxx call.

To put it another way, I'm thinking from the perspective of that thread 1,
lets say it posts a beginReceive operation and it is concerned only with
when *all* the expected data is received, regardless of how many times the
receive callback iterates by repeating calls to beginReceive. The
IAsyncResult interface has the IsCompleted property and an AsyncWaitHandle.
So if that original IAsyncResult reference from thread 1 'followed' the
'whole operation from thread 1's perspective', it could be used to check on
completion status or wait from thread 1. Again, I assume this is not the
case and probably sounds real silly to those that know what their doing. I
assume the fact is that the IAsyncResult references only the one beginxxx
call it was created from, right?

I realize there are many other ways to accomplish what this example shows...
not looking to solve that, just wondering specifically about the
IAsyncResult with beginxxx() async calls.

any input is appreciated, laughing is perfectly acceptable as well,
considering I can't hear you ;)
Jun 15 '07 #1
2 3661
David,

While you are right, you can't take the result from the first async
operation (the IAsyncResult implementation) and use that to monitor the
larger operation (which involves multiple async operations), there is no
reason you can not abstract this out yourself.

For example, it would be very simple to have a boolean value somewhere
(with synchronized access, of course) and set that flag to true when the
overall operation is complete (which will be in one of your callbacks).
Then, thread 1 can just check the value when it needs to see if the
operation is complete.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"David" <no****@nospam.comwrote in message
news:uY**************@TK2MSFTNGP04.phx.gbl...
>I don't actually have a need to do this right now but was wondering... I
also assume the answer to this is going to be no but....

thread 1 calls an async socket.beginReceive() method which returns an
IAsyncResult. So at that moment thread 1 has this IAsyncResult. If the
callback method for that beginReceive calls beginReceive again, will
thread 1's IAsyncResult reference from that first beginxxx call now
reference the second call, and so on? I assume no, it would produce a new
IAsyncResult object for each new beginxxx call.

To put it another way, I'm thinking from the perspective of that thread 1,
lets say it posts a beginReceive operation and it is concerned only with
when *all* the expected data is received, regardless of how many times the
receive callback iterates by repeating calls to beginReceive. The
IAsyncResult interface has the IsCompleted property and an
AsyncWaitHandle. So if that original IAsyncResult reference from thread 1
'followed' the 'whole operation from thread 1's perspective', it could be
used to check on completion status or wait from thread 1. Again, I assume
this is not the case and probably sounds real silly to those that know
what their doing. I assume the fact is that the IAsyncResult references
only the one beginxxx call it was created from, right?

I realize there are many other ways to accomplish what this example
shows... not looking to solve that, just wondering specifically about the
IAsyncResult with beginxxx() async calls.

any input is appreciated, laughing is perfectly acceptable as well,
considering I can't hear you ;)

Jun 15 '07 #2
Thanks Nicholas. Got it.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:%2***************@TK2MSFTNGP06.phx.gbl...
David,

While you are right, you can't take the result from the first async
operation (the IAsyncResult implementation) and use that to monitor the
larger operation (which involves multiple async operations), there is no
reason you can not abstract this out yourself.

For example, it would be very simple to have a boolean value somewhere
(with synchronized access, of course) and set that flag to true when the
overall operation is complete (which will be in one of your callbacks).
Then, thread 1 can just check the value when it needs to see if the
operation is complete.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"David" <no****@nospam.comwrote in message
news:uY**************@TK2MSFTNGP04.phx.gbl...
>>I don't actually have a need to do this right now but was wondering... I
also assume the answer to this is going to be no but....

thread 1 calls an async socket.beginReceive() method which returns an
IAsyncResult. So at that moment thread 1 has this IAsyncResult. If the
callback method for that beginReceive calls beginReceive again, will
thread 1's IAsyncResult reference from that first beginxxx call now
reference the second call, and so on? I assume no, it would produce a
new IAsyncResult object for each new beginxxx call.

To put it another way, I'm thinking from the perspective of that thread
1, lets say it posts a beginReceive operation and it is concerned only
with when *all* the expected data is received, regardless of how many
times the receive callback iterates by repeating calls to beginReceive.
The IAsyncResult interface has the IsCompleted property and an
AsyncWaitHandle. So if that original IAsyncResult reference from thread 1
'followed' the 'whole operation from thread 1's perspective', it could be
used to check on completion status or wait from thread 1. Again, I assume
this is not the case and probably sounds real silly to those that know
what their doing. I assume the fact is that the IAsyncResult references
only the one beginxxx call it was created from, right?

I realize there are many other ways to accomplish what this example
shows... not looking to solve that, just wondering specifically about the
IAsyncResult with beginxxx() async calls.

any input is appreciated, laughing is perfectly acceptable as well,
considering I can't hear you ;)


Jun 15 '07 #3

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

Similar topics

3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
1
by: mail.matty | last post by:
Hi All, I've been working on a library which does async Http operations. The library is exposed to COM as I need to access it via SQL2000. Whenever the following line of code executes it...
3
by: FefeOxy | last post by:
Anyone know the difference between these 2?
0
by: ssabusivefw | last post by:
I am basically writing a server/client application. The client application starts on the login in form where the user is required to enter a user name and password. These are encrypted sent to the...
12
by: semedao | last post by:
Hi all, someone know if I can use the IAsyncResult.IsCompleted Property of IAsyncResult that return from Socket.Beginxxx methods to determine if the Endxxx method already called perior or not ? I...
2
by: David | last post by:
If I were to call an async beginxxx method that returns an IAsyncResult when exactly would the AsyncWaitHandle be signaled? Before or after the corresponding endxxx method completes? Immediately...
2
by: Morgan Cheng | last post by:
In asynchronous model, BeginXXX method returns a IAsnycResult-derived object. IAsyncResult.AsyncWaitHandle will be signaled when the asynchronous job is complete; and BeginXXX method has a argument...
0
by: UL-Tomten | last post by:
Is the WaitHandle on the IAsyncResult returned from BeginProcessRequest ever used by the HTTP application? The reason I'm asking is that in the MSDN article "How to: Create an Asynchronous HTTP...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.