Not a Monotouch developer either, but I'd assume you can ignore this warning, unless you're really interested in observing the completion of the task returned by the HandleNextStep()
asynchronous call.
The following would suppress the warning in VS 2012:
this.txt.ShouldReturn = textField =>
{
var task = this.HandleNextStep(); // presumably, no more warning
return true;
};
If you actually like to observe the status of the task, you could do something like this (no more warning):
Task _handleNextStepTask; // a member variable
// ...
this.txt.ShouldReturn = textField =>
{
this._handleNextStepTask = this.HandleNextStep().ContinueWith(
t => Debug.Print("NextStepHandled"),
TaskScheduler.FromCurrentSynchronizationContext());
return true;
};
Or even something like below, if you really don't want to store the Task
object anywhere, still no more warning:
this.txt.ShouldReturn = textField =>
{
(new Action(async () =>
{
try
{
await this.HandleNextStep();
// executed synchronously until this point
Debug.Print("NextStepHandled");
}
catch (Exception ex)
{
// catch all exceptions inside "async void" lambda
Debug.Print(ex.Message);
}
}))();
return true;
};
The latter approach might be perceived as code smell, but I think in this specific case it can be used.