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.ReadLin e() ", the method DOESN'T get
invoked.
Can anyone tell me why? Does the call require a pause?
(ErrorInformati on is a serializable struct - for those who are
wondering)
Here's my code:
=========
private void Write(ErrorInfo rmation ei) {
HttpChannel channel = new HttpChannel();
ChannelServices .RegisterChanne l(channel);
IRemoteObject obj = (IRemoteObject) Activator.GetOb ject(
typeof(IRemoteO bject),
"http://localhost:50000/ServerException Log.soap");
RemoteWriteDele gate rwrDelegate = new RemoteWriteDele gate(obj.Write) ;
IAsyncResult rwrAsyncres = rwrDelegate.Beg inInvoke(ei, null, null);
try {
rwrDelegate.End Invoke(rwrAsync res);
}catch(Exceptio n e) {
//do something
}
// wait for keypress
Console.ReadLin e();
}
========= 4 1751
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.co m
"wobbles" <no************ *************** @killspam.hotma il.com> wrote in
message news:5f******** *************** *********@4ax.c om... 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.ReadLin e() ", the method DOESN'T get invoked.
Can anyone tell me why? Does the call require a pause? (ErrorInformati on is a serializable struct - for those who are wondering)
Here's my code: ========= private void Write(ErrorInfo rmation ei) {
HttpChannel channel = new HttpChannel(); ChannelServices .RegisterChanne l(channel); IRemoteObject obj = (IRemoteObject) Activator.GetOb ject( typeof(IRemoteO bject), "http://localhost:50000/ServerException Log.soap");
RemoteWriteDele gate rwrDelegate = new RemoteWriteDele gate(obj.Write) ; IAsyncResult rwrAsyncres = rwrDelegate.Beg inInvoke(ei, null, null);
try { rwrDelegate.End Invoke(rwrAsync res); }catch(Exceptio n e) { //do something }
// wait for keypress Console.ReadLin e();
} =========
>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...curr ently 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.
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.co m
"wobbles" <no************ *************** @killspam.hotma il.com> wrote in
message news:ld******** *************** *********@4ax.c om... 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...curr ently 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.
>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! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 experiencing the
slow speed on the server side. I read that using a delegate to call an asynchronous metho
would be ineffecient and maybe causing the problem. Can someone give me some advice on wha
i can do to improve the speed without doing a...
|
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 records being inserted? Am I just making a
mistake somewhere? (though I don't get double the records if I call the
method synchronously.)
Thanks,
Darryl
|
by: Sharon |
last post by:
How to catch an asynchronous delegate invocation exception?
The code:
---------------------------------------
String message = “my message”;
foreach( MyDelegate handler in m_MyDelegate.GetInvocationList() )
{
try
{
handler.BeginInvoke(message, null, null);
|
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 asynchronously. This is fine. My problem is that when I make a call to the web service asynchronously when I get the return which is passed into a static method I cannot reference any Web Contorls to paste the return values into from within the static method....
|
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 MathWS( the class name),and put it in a
..asmx file named math.asmx in the "D:/winnt/interpub/wwwroot/mathws"
directory. "mathws" is my new-built directory.
2.run the http://localhost/mathws/math.asmx,find it works well,and run run
the...
| |
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
1.07/Linux, Firefox 1.5/Linux, Firefox 1.5/Windows and Firefox 1.5/Mac,
Safari/Mac.
It works perfectly on a lot of configurations but, on some PC with
Firefox 1.5/Windows (not all), the Javascript code with XmlHttpRequest
|
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
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
|
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 completes it invokes a method from the calling thread. Sort event driven concept with threads.
Thanks.
Ed Gomez
|
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:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 projectplanning, coding, testing, and deploymentwithout 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...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |