C# 可靠参与者内的异步调用是否会破坏基于回合的并发性?
我在服务结构可靠参与者中使用以下方法:C# 可靠参与者内的异步调用是否会破坏基于回合的并发性?,c#,azure,azure-service-fabric,C#,Azure,Azure Service Fabric,我在服务结构可靠参与者中使用以下方法: async Task IRoomActor.ReportUpdateAsync(SensorCacheItem sensorItem, CancellationToken cancellationToken) { try { //get the state of this room RoomState roomState = await GetOrCreateState
async Task IRoomActor.ReportUpdateAsync(SensorCacheItem sensorItem, CancellationToken cancellationToken)
{
try
{
//get the state of this room
RoomState roomState = await GetOrCreateState(sensorItem.RoomId, cancellationToken);
//update state based on the sensor cache item passed in
var existingItem = roomState.Sensors.FirstOrDefault(s => s.SensorRowId == sensorItem.SensorRowId);
if (existingItem != null)
{
roomState.Sensors.Remove(existingItem);
}
roomState.Sensors.Add(sensorItem);
//update status based on sensors
ResolveStatusFromSensors(roomState, sensorItem);
//save or update the state
await StateManager.AddOrUpdateStateAsync(ServiceConstants.RoomActorStateName, roomState,
(key, value) => roomState, cancellationToken);
await SaveStateAsync();
//send updates to Floor Actor
await PropagateStateToParent(roomState, cancellationToken);
}
catch (Exception e)
{
ActorEventSource.Current.ActorMessage(this, $"Exception thrown in RoomActor.ReportUpdateAsync(): {e.StackTrace}");
throw;
}
}
此方法中等待的调用是否会破坏可靠参与者基于回合的并发性?否,这不会影响基于回合的并发性,因为从ReportUpdateSync返回的整个任务(包括其内部等待)必须在允许下一个调用进入之前完成。太好了!多谢