New Posts New Posts RSS Feed: Coroutine.Cancel() and Custom Operations
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Coroutine.Cancel() and Custom Operations

 Post Reply Post Reply
Author
ken.nelson View Drop Down
Groupie
Groupie


Joined: 03-Mar-2009
Location: Ann Arbor, MI
Posts: 54
Post Options Post Options   Quote ken.nelson Quote  Post ReplyReply Direct Link To This Post Topic: Coroutine.Cancel() and Custom Operations
    Posted: 05-Jul-2012 at 6:57am
Yeah that's what I was concerned about. We don't inherit from BaseOperation, just INotifyCompleted, so even though we have a Cancel() method and a Cancelled property, they'll never be called.
 
We might be in the same boat with respect to web services, but at the very least I'd like to abort the client, unwire event-handlers and close it down properly.
 
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: 03-Jul-2012 at 2:01pm
If a Coroutine operation inherits from BaseOperation the Cancel request will also try to cancel that operation.
 
One thing to note though, is that a web service request might not be truly cancellable anyway.  This is the case for the async requests to the EntityServer - the underlying service operations cannot be cancelled, but we do stop tracking them when cancel is requested.
Back to Top
ken.nelson View Drop Down
Groupie
Groupie


Joined: 03-Mar-2009
Location: Ann Arbor, MI
Posts: 54
Post Options Post Options   Quote ken.nelson Quote  Post ReplyReply Direct Link To This Post Posted: 03-Jul-2012 at 1:34pm

I'm wondering what the Coroutine.Cancel method is doing under the hood. The Remarks section states that all operations which haven't yet completed will be cancelled. The reason I'm asking is because we've written our own Operations that implement the INotifyCompleted interface. These operations allow us to call our custom web-service methods inside a Coroutine, but since INotifyCompleted doesn't define Cancel(), I'm wondering how Coroutine.Cancel() would know how to cancel it.

 

Really I guess the bottom-line question is: What do we have to do to make sure our custom Operations are properly cancelled when used inside a Coroutine and Coroutine.Cancel is called?

 

 

// Summary:

//     Cancel a currently running coroutine.

//

// Parameters:

//   coroutineOperation:

//

// Remarks:

//     If the iterator is still running, cancels all operations which haven't yet

//     completed.

public static void Cancel(CoroutineOperation coroutineOperation);

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down