New Posts New Posts RSS Feed: Async Queries: handling sudden disconnect
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Async Queries: handling sudden disconnect

 Post Reply Post Reply
Author
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Topic: Async Queries: handling sudden disconnect
    Posted: 19-Nov-2008 at 5:37pm
Ah, okay.  The GetEntitiesCompletedHandler in that tutorial is not checking the GetEntitiesCompletedEventArgs to see if the operation was either cancelled or in error before trying to access the Entities property in ResetAsyncQuery().  These args are a subclass of System.ComponentModel.AsyncCompletedEventArgs, and the event-based pattern indicates that an exception should be raised when trying to access result properties after a cancel or error.  Here's more information: http://msdn.microsoft.com/en-us/library/system.componentmodel.asynccompletedeventargs.aspx.
Back to Top
kjohnson View Drop Down
Newbie
Newbie


Joined: 19-Nov-2008
Posts: 19
Post Options Post Options   Quote kjohnson Quote  Post ReplyReply Direct Link To This Post Posted: 19-Nov-2008 at 12:39pm
I'm using DevForce 3.6.3 and testing this scenario in a 2-tier client-server environment.  I'll try checking PersistenceServerError handler to see if anything is happening there.  As a note, the ResetAsyncQuery() and GetEntitiesCompleted Handler() listed in the exception text are unchanged from the async query tutorial.

************** Exception Text **************
System.InvalidOperationException: Operation has been cancelled.
   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
   at IdeaBlade.Persistence.GetEntitiesCompletedEventArgs.get_Entities()
   at FrontEnd.XtraMainForm2.ResetAsyncQuery(GetEntitiesCompletedEventArgs e)
   at FrontEnd.XtraMainForm2.GetEntitiesCompletedHandler(Object sender, GetEntitiesCompletedEventArgs e)
   at IdeaBlade.Persistence.PersistenceManager.OnGetEntitiesCompleted(GetEntitiesCompletedEventArgs pArgs)
   at IdeaBlade.Persistence.PersistenceManager.AsyncFetchCompleted(Object pFetchState)

Stack Trace:
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at FrontEnd.Program.Main() in \\optimus\Public\Kevin\RealTimePOS\Project Files\FrontEnd\FrontEnd\Program.cs:line 23
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 19-Nov-2008 at 11:11am
In theory, a call to PM.CancelAsync() should succeed even if the operation was already cancelled -- is this where the exception is thrown? 
 
Depending on the timing of events, it's possible that you could see the connection failure in your PersistenceServerError handler.  When the PM detects connection failures it will also enter some retry logic, so that might be confusing things.
 
What version of DevForce are you using, and are you using WCF or remoting for communications to the BOS?  Can you also post the full text and stack trace of the exception?
Back to Top
kjohnson View Drop Down
Newbie
Newbie


Joined: 19-Nov-2008
Posts: 19
Post Options Post Options   Quote kjohnson Quote  Post ReplyReply Direct Link To This Post Posted: 19-Nov-2008 at 8:49am
The application I'm currently working on is using asynchronous queries to keep data up to date.  I'm also working to get my application to work while disconnected from the network.  The problem I am having is concerning sudden loss of network connectivity.  I've set up my program to detect when connectivity is lost (loss of network in a client-server, loss of internet in an n-tier), and then cancel the asynchronous queries until connectivity is restored.  Unfortunately, I'm getting an error that the 'operation has been canceled' when I cancel the async queries.

I'm canceling and restarting the async queries elsewhere without problems.  It is only during this sudden loss of connectivity situation I'm testing that I have a problem.  Is there a certain exception being thrown I'm not handling, or would you suggest another way to handle this situation?  Or is there documentation I missed that will help?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down