I am getting the following error
Error CS4010 Cannot convert async lambda expression to delegate type 'TaskAction'. An async lambda expression may return void, Task or Task, none of which are convertible to 'TaskAction'
My function looks like this:
public async void GetLastKnownUpdateStatus(string UUIDStr, short ClientId)
{
UpdateStatusInfo x = new UpdateStatusInfo();
if (Execution.WaitForTask(async (canceltoken) => { x = await GetLastKnownUpdateStatus(UUIDStr, ClientId); return true; }) > Execution.WAIT_TIMEOUT)
{
Output.WriteLine("GetLastKnownUpdateStatus: "+ x.State.ToString());
}
}
This method calls the following function:
public Task<UpdateStatusInfo> GetLastKnownUpdateStatus(string uniqueUpdateID, short clientID)
{
return GetLastKnownUpdateStatus(uniqueUpdateID, clientID, null);
}
any help is appreciated
Execution.WaitForTask comes from Vector.CANoe.Threading class and is defined by Vector as following
//
// Summary:
// Executes a task in a separate thread. During the wait, the measurement and simulation
// are not blocked. Optionally returns failure after a certain timespan.
//
// Parameters:
// taskAction:
// A delegate function to execute in a separate task
//
// maxTime:
// Optional: maximum time to wait, in milliseconds.
//
// Returns:
// WAIT_TIMEOUT: if an maxTime was defined and the task did not return within maxTime
// milliseconds WAIT_ABORTED: if the measurement was stopped during task execution
// WAIT_EXCEPTION: if an exception occurred in the taskAction delegate WAIT_ILLEGAL_RESULTVALUE:
// the result provided by the task is <= 0 > 0 any positive result provided by the
// taskAction delegate (only use numbers > 0 as return values)
//
// Remarks:
// Be careful: You may not use most of the CANoe API functions in the taskAction.
// Allowed is: Modifying SystemVariables Using Output.* functions See documentation
// for details
TaskActionis, and it's never mentioned in the code you've provided. We also don't know whatExecution.WaitForTaskis. Without all the relevant information, we're not going to be able to help. - Jon Skeet