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

HELP PLEASE: How do you timeout with an IpcChannel?

Hi. I have two appications - a GUI and a main engine. The GUI talks to the engine using IPCChannels.

If I shutdown the engine, the GUI can still call a method on the interface provided by IPCChanel but it sits there forever. How can I detect if the engine (server) has shutdown?

I did try using BeginInvoke() on a delegate so that I could make my call asynchronously and then timeout after 'x' amount of time but then how do you stop an invoked IPCChannel call? I called EndInvoke() and this froze up my client GUI application.

Help would be really appreciated.

Thanks

Paul
Aug 28 '07 #1
1 2196
Some code example would be helpful, but I guess you have done something like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. // wrap the delegate around the ipc call method
  3. IpcChannelCallDelegate channelCall = new IpcChannelCallDelegate(channelCall);
  4. // start the ipc call asychronously
  5. IAsyncResult asyncResult = channelCall.BeginInvoke(param, null, null);
  6.  
  7. // -PLACEHOLDER-
  8.  
  9. // get the result from the ipc call
  10. result = channelCall.EndInvoke(asyncResult);
  11.  
  12.  
Suppose now the ipc server goes down when the client code reaches the -PLACEHOLDER- the EndInvoke would return some mess.

One solution would be to add some timeout mechanism. Since you are using BeginInvoke and EndInvoke try this:

Expand|Select|Wrap|Line Numbers
  1. IpcChannelCallDelegate channelCall = new IpcChannelCallDelegate(channelCall);
  2. IAsyncResult asyncResult = channelCall.BeginInvoke(param, null, null);
  3.  
  4. // this one is new:
  5. while (!asyncResult.AsyncWaitHandle.WaitOne(5000, false))
    if (!asyncResult.IsCompleted) throw new TimeoutException();
    result = channelCall.EndInvoke(asyncResult);
  6.  
The while condition would evaluate after 5000 msec to true and if the asynchronous ipc call still yields no results a TimeoutException will be thrown, which you have to catch somewhere else.

And consider to use the ChannelServices.UnregisterChannel to avoid any new ipc calls after that exception.

Greetings,
K

Hi. I have two appications - a GUI and a main engine. The GUI talks to the engine using IPCChannels.

If I shutdown the engine, the GUI can still call a method on the interface provided by IPCChanel but it sits there forever. How can I detect if the engine (server) has shutdown?

I did try using BeginInvoke() on a delegate so that I could make my call asynchronously and then timeout after 'x' amount of time but then how do you stop an invoked IPCChannel call? I called EndInvoke() and this froze up my client GUI application.

Help would be really appreciated.

Thanks

Paul
Feb 7 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
5
by: Jason | last post by:
Hi all I get the following error when executing a rather intense stored procedure from an ASPX page. I have tried: - Increasing timeouts on IIS 5.0 (all areas that even mention timeout) - use...
0
by: cody | last post by:
if I create an instance of the IpcChannel class with a normal user account I get a security exception. Is there a way I can avoid this exception?
0
by: Calvin KD | last post by:
Hi everyone, I need help urgently. I have a C#.Net app which uses cookies for state management. Everything has been going fine until recently we've expanded the app and a few more screens were...
3
by: Grant Schenck | last post by:
I have a simple remoting sample using IPCChannel. If I run the server code as a console app my client can connect just fine. However, if I the same server code runs in a service, the client gets...
2
by: Orgil | last post by:
I'm using ASP 3.0 however there is ASP.NET, because I'm working an old site that is built in ASP 3.0. I hope you for getting any help for my problem from you. So, my site's sessions are empty...
2
by: =?Utf-8?B?cXVpbGtpbg==?= | last post by:
Hi, I have a Windows service which communicates to a user app via IpcChannel remoting. It all works fine until the service is stopped and restarted (or restarted via Management Console Services),...
2
by: violeta123 | last post by:
I am stuck! Please help It might be difficult to explain the problem via email, but I will try. I have a Win 2003 Enterprise server running with the only purpose of a membership web site...
1
by: Ajb181 | last post by:
hi all. i have a template class that i can not link. there is no problem when i add the method def's inside the header file but as soon as i move them out i get a link error where i define the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.