Je réécrit une partie du C# dans ce laboratoire à F #: https://github.com/Microsoft/TechnicalCommunityContent/tree/master/IoT/Azure%20Stream%20Analytics/Session%202%20-%20Hands%20OnAsync en F # Attendent
Je suis sur l'exercice 6, # 17 - la création du type SimpleEventProcessor
.
Je veux mettre en œuvre la méthode CloseAsync
C#
async Task IEventProcessor.CloseAsync(PartitionContext context, CloseReason reason)
{
Debug.WriteLine("Processor Shutting Down. Partition '{0}', Reason: '{1}'.", context.Lease.PartitionId, reason);
if (reason == CloseReason.Shutdown)
{
await context.CheckpointAsync();
}
}
et j'ai commencé comme ceci:
member this.CloseAsync(context, reason) =
Debug.WriteLine("Processor Shutting Down. Partition '{0}', Reason: '{1}'.", context.Lease.PartitionId, reason)
match reason with
| CloseReason.Shutdown -> await context.CheckpointAsync()
| _ ->()
mais j'ai 2 questions:
- Comment puis-je retourner attendre dans F # monde?
- Comment renvoyer le cas NOT -> C# ignore juste cette possibilité.
le IEventProcessor CloseAsync renvoie une tâche. Donc | CloseReason.Shutdown -> context.CheckpointAsync() fonctionne. Besoin de savoir comment renvoyer une tâche vide –
L'a fait: match reason avec | CloseReason.Shutdown -> context.CheckpointAsync() | _ -> Task.CompletedTask –
Ah, désolé, j'ai mal lu votre question, d'une certaine manière je pensais que vous étiez en train de passer de la tâche à l'asynchrone en plus de passer de C# à F #. – Tarmil