473,586 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.beginRec eive() 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 3666
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.co m

"David" <no****@nospam. comwrote in message
news:uY******** ******@TK2MSFTN GP04.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.beginRec eive() 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.c omwrote in
message news:%2******** *******@TK2MSFT NGP06.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.co m

"David" <no****@nospam. comwrote in message
news:uY******** ******@TK2MSFTN GP04.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.beginRec eive() 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
AsyncWaitHandl e. 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
5021
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
3075
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 before rowID answID qryrow questionID datafield 1591 12 06e 06e 06e question 1593 12 06f 06f 06f question 1594 12 answer to the question 06f
1
1862
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 generates the 'Object Reference...' error. IAsyncResult result = (IAsyncResult) req.BeginGetResponse(new AsyncCallback(RespCallback), myRequestState);
3
2133
by: FefeOxy | last post by:
Anyone know the difference between these 2?
0
1214
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 server which the server checks against know users. If the user has enter the correct information the server sends back the code <LIGO> which is...
12
4617
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 have methods that return the IAsyncResult after I called begin... (connect for example) and I want to know if I should call the EndConnect or not...
2
3166
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 after?
2
2197
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 as AsyncCallback to be invoked when the job is complete. I am wondering. When the asynchronous is complete, is IAsyncResult.AsyncWaitHandle be...
0
1803
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 Handler", BeginProcessRequest() returns an IAsyncResult whose AsyncWaitHandle getter always returns null. Why is this? Is there some guarantee that...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7959
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
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...
0
6614
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...
1
5710
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...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.