New Posts New Posts RSS Feed: Question abour results from coroutine
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Question abour results from coroutine

 Post Reply Post Reply
Author
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Topic: Question abour results from coroutine
    Posted: 04-Dec-2010 at 10:56pm
I created my coroutine and my iterator. I have my yield returns after every asynchronous query and I have my yield return corroutine at the end of the iterator method.
 
Here is my problem. When the args.CompletedSuccessfully is reached there are 25 rows of the entity type I am returning. Here is my code. When the ResetStepTypesList is reached the variable is null. what am I doing wrong in the parameter to ResetStepTypesList method?
 

public void GetAvailableSteps()

{

var steps = Coroutine.Start(() => AvailableStepsSelector.RetrieveAvailableSteps(currentEvent));

steps.Completed += (sender, args) =>{

if (args.CompletedSuccessfully){

ResetStepTypesList(steps.Result as IEnumerable<EventStepType>);            //Results = 25 rows 

}

else{

}

};

}

public void ResetStepTypesList(IEnumerable<EventStepType> stepTypes) steps == null at this point

{

StepTypes.Clear();

stepTypes.ForEach(StepTypes.Add);

OnPropertyChanged("StepTypes");

}

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: 06-Dec-2010 at 10:44am
I'll have to guess here, since I can't reproduce the problem, but it's likely an issue with the cast in the call to ResetStepTypesList.  If the result isn't truly an IEnumerable<EventStepType> the as operator will return a null, and that null would be passed to the function. 
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 06-Dec-2010 at 11:17am
If I set a breakpoint at the call to ResetEventTyepsList method call I can see a 25 for the number in Reulsts. So If I cast steps.Result to ObservableCollection<EventStepType> does tat access the Results value?
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: 06-Dec-2010 at 11:22am
Try a steps.Result.GetType() to see the actual type in the IEnumerable.  You could also try the cast before calling the method and test it explicitly:
 
var myResult = steps.Result as IEnumerable<EventStepType>;
if (myResult == null) { ...casting issue }

Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 06-Dec-2010 at 2:47pm
Strange. When I check the following line.
 

var Results = steps.Result as ObservableCollection<EventStepType>;

Steps.results = 25 and they are of type EventStepType

but Results = null after the line is executed.

Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 07-Dec-2010 at 7:42am
When the Coroutine.Return occurs, the data type is
 
System.Collections.ObjectModel.ReadOnlyCollecton <EventStepType>   Results count = 26
 
in my Args.CompletedSuccessfully code, I do a GetType() and the data type is
 
IdeaBlade.EntityModel.EntityQueryOperations <EventStepType>
 
so what do I need to cast it to in order to get it into my ObservableCollection
 
var results = steps.Result as ?????????????????
 
ResetStepTypesList(results)
 
 
public ResetStepTypeList(<EventStepType> stepsTypes)
{
       this.StepTypes.Clear();
       stepTypes.foreach(StepTypes.Add);
}
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down