New Posts New Posts RSS Feed: Coroutine methods and UserState
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Coroutine methods and UserState

 Post Reply Post Reply
Author
stephenmcd1 View Drop Down
DevForce MVP
DevForce MVP


Joined: 27-Oct-2009
Location: Los Angeles, CA
Posts: 166
Post Options Post Options   Quote stephenmcd1 Quote  Post ReplyReply Direct Link To This Post Topic: Coroutine methods and UserState
    Posted: 27-Oct-2010 at 7:03pm
It appears that none of the methods on the Coroutine class (Start, StartParallel) take a userState parameter even though the resulting CoroutineOperation has a UserState property - and pretty much all other query-related methods in DevForce provide the userState parameter.  Is this just an oversight?  Can a userState parameter be added to the Coroutine methods?

Thanks!
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: 28-Oct-2010 at 11:06am
In some ways UserState is a legacy of our older async API when async operations did not return a xxOperation (EntityQueryOperation, EntitySaveOperation, etc).  The UserState is used internally to track every async operation uniquely, and can also be used to cancel an async operation.  I guess we tend to forget the fact that it can be used to pass user-defined information between the calling method and the callback.
 
In the case of the Coroutine Start methods, because the Coroutine is not itself asynchronous DevForce does not need a UserState.  A UserState is assigned to the CoroutineOperation, but only because that class is a sub-type of the BaseOperation and a UserState is automatically assigned.   Because the UserState isn't used by DevForce in the Coroutine, we didn't provide a means of providing it.  You can pass parameters into the iterator block via the Start methods, however, and this does in some way give you the same functionality as a user-defined UserState.
 
We can certainly look at adding a UserState parameter to the Start methods and have opened a feature request for this.  Thanks for the feedback.
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down