473,387 Members | 1,606 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,387 software developers and data experts.

strange problem with Asynchronous call

Hi Everyone,

I've spent hours investigating why my Async (one way) call wasn't
invoking the method on my server.

Basically, if I remove " Console.ReadLine() ", the method DOESN'T get
invoked.

Can anyone tell me why? Does the call require a pause?
(ErrorInformation is a serializable struct - for those who are
wondering)
Here's my code:
=========
private void Write(ErrorInformation ei) {

HttpChannel channel = new HttpChannel();
ChannelServices.RegisterChannel(channel);
IRemoteObject obj = (IRemoteObject) Activator.GetObject(
typeof(IRemoteObject),
"http://localhost:50000/ServerExceptionLog.soap");

RemoteWriteDelegate rwrDelegate = new RemoteWriteDelegate(obj.Write);
IAsyncResult rwrAsyncres = rwrDelegate.BeginInvoke(ei, null, null);
try {
rwrDelegate.EndInvoke(rwrAsyncres);
}catch(Exception e) {
//do something
}

// wait for keypress
Console.ReadLine();

}
=========
Nov 15 '05 #1
4 1713
wobbles,

Is it possible that you are calling the Write method and then exiting
the application? If so, it is possible that your application is shutting
down before the call can be remoted to the server.

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

"wobbles" <no***************************@killspam.hotmail.co m> wrote in
message news:5f********************************@4ax.com...
Hi Everyone,

I've spent hours investigating why my Async (one way) call wasn't
invoking the method on my server.

Basically, if I remove " Console.ReadLine() ", the method DOESN'T get
invoked.

Can anyone tell me why? Does the call require a pause?
(ErrorInformation is a serializable struct - for those who are
wondering)
Here's my code:
=========
private void Write(ErrorInformation ei) {

HttpChannel channel = new HttpChannel();
ChannelServices.RegisterChannel(channel);
IRemoteObject obj = (IRemoteObject) Activator.GetObject(
typeof(IRemoteObject),
"http://localhost:50000/ServerExceptionLog.soap");

RemoteWriteDelegate rwrDelegate = new RemoteWriteDelegate(obj.Write);
IAsyncResult rwrAsyncres = rwrDelegate.BeginInvoke(ei, null, null);
try {
rwrDelegate.EndInvoke(rwrAsyncres);
}catch(Exception e) {
//do something
}

// wait for keypress
Console.ReadLine();

}
=========

Nov 15 '05 #2
>wobbles,

Is it possible that you are calling the Write method and then exiting
the application? If so, it is possible that your application is shutting
down before the call can be remoted to the server.

Hope this helps.

Hi Nicholas,

Ah...yes...currently it's in a console application testbed.
Thinking about it, when I call the method from within a "normal" app
(ie windows form or similar) the app won't exit so the problem
shouldn't be there.

Thanks for that. I can see that in "real life", it won't be a problem.

From a technical point, what we're saying is: the app needs to be
alive for the call to persist?
Shouldn't the call continue onto the server even if the client app
exits? I thought that was the point of calling EndInvoke?

In that case, is there some way for me to know if the call has been
remoted or not, before my app exits?

Thanks again,
wobbles
P.S. The only reason I use "one way" is because I don't want my client
to care if the server is running or not. If it is running, great. If
not, it's not critical because it's only for logging.
Nov 15 '05 #3
wobbles,

Well, yes, you have to disable one-way semantics (remove the OneWay
attribute) so that you get a notification when the call is complete. You
can either do this by making the method call (which will block), or by
setting up a callback for when the response returns.

The reason the call doesn't go through is that when your thread exits,
it shuts down the runtime, and chances are the call hasn't been placed on
the wire before the runtime shuts down, so the server never gets the call.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"wobbles" <no***************************@killspam.hotmail.co m> wrote in
message news:ld********************************@4ax.com...
wobbles,

Is it possible that you are calling the Write method and then exiting
the application? If so, it is possible that your application is shutting
down before the call can be remoted to the server.

Hope this helps.

Hi Nicholas,

Ah...yes...currently it's in a console application testbed.
Thinking about it, when I call the method from within a "normal" app
(ie windows form or similar) the app won't exit so the problem
shouldn't be there.

Thanks for that. I can see that in "real life", it won't be a problem.

From a technical point, what we're saying is: the app needs to be
alive for the call to persist?
Shouldn't the call continue onto the server even if the client app
exits? I thought that was the point of calling EndInvoke?

In that case, is there some way for me to know if the call has been
remoted or not, before my app exits?

Thanks again,
wobbles
P.S. The only reason I use "one way" is because I don't want my client
to care if the server is running or not. If it is running, great. If
not, it's not critical because it's only for logging.

Nov 15 '05 #4
>wobbles,

Is it possible that you are calling the Write method and then exiting
the application? If so, it is possible that your application is shutting
down before the call can be remoted to the server.

Hope this helps.

I went through Ingo's book again and at the bottom of the page of
Async oneway calls, I found this:

<Quote>
"...The interesting thing is that when using [OneWay()], the call to
EndInvoke() finishes before the server completes the method. This is
because in reality the client just ignores the server's response when
using one-way method calls...."
</Quote>

I think I understand now why this is.
If the client doesn't care (or know) if the server is running,
"EndInvoke" wouldn't know how long to wait to find out if the method
has been invoked or not.

Personally, I would like to have seen EndInvoke do its business (as a
non-oneway Async call would do) with the difference being that if the
Server doesn't exist, NO exception is thrown.

Then again I don't know if this would have been possible due to the
reasons mentioned above.
Thanks again for your help!
Nov 15 '05 #5

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

Similar topics

1
by: hs | last post by:
H I am using the articles by Matt Powell about server side asynchronous web methods (as well as the client side article) However i dont see any improvements to the speed of my application. I'm...
2
by: Darryl A. J. Staflund | last post by:
Hi there, Can anyone tell me why invoking a single SQL insert statement (well, rather, a method that performs a SQL insert) using an asynchronous delegate should result in twice the number of...
6
by: Sharon | last post by:
How to catch an asynchronous delegate invocation exception? The code: --------------------------------------- String message = “my message”; foreach( MyDelegate handler in...
8
by: Trotsky | last post by:
Hi I have asked a similar question on the web services discussion group, but the question is a bit more related to ASP.Net. Basically I have a ASP.Net application that calls a web service...
0
by: han zhiyang | last post by:
I've just studied the "how to" web service and the async pattern in donnet.I make a test with these knowledges,but I got a strange result. Here is my test. 1.Write a simple "Add" service named...
42
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
4
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
5
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...
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?
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:
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...
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
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...

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.