@@ -60,19 +60,13 @@ There are several ways to execute an async workflow:
6060*)
6161
6262let runAsyncExample () =
63+ // Run synchronously (blocking) - simplest approach
64+ let result = fetchDataAsync () |> Async.RunSynchronously
65+
6366 // Start immediately (non-blocking) - Ignore discards the result
6467 fetchDataAsync () |> Async.Ignore |> Async.StartImmediate
6568
66- // Run synchronously (blocking)
67- let result = fetchDataAsync () |> Async.RunSynchronously
68-
69- // Start with explicit continuations
70- Async.StartWithContinuations(
71- fetchDataAsync (),
72- ( fun result -> printfn $" Success: {result}" ),
73- ( fun ex -> printfn $" Error: {ex.Message}" ),
74- ( fun cancelled -> printfn " Cancelled" )
75- )
69+ result
7670
7771(**
7872### Combining Async Operations
@@ -351,6 +345,22 @@ let runWithTimeout () =
351345 return None
352346 }
353347
348+ (**
349+ ### Advanced: StartWithContinuations
350+
351+ For fine-grained control over success, error, and cancellation outcomes, use
352+ ` Async.StartWithContinuations ` . This is useful when you need different handling paths
353+ for each case:
354+ *)
355+
356+ let runWithContinuations () =
357+ Async.StartWithContinuations(
358+ fetchDataAsync (),
359+ ( fun result -> printfn $" Success: {result}" ),
360+ ( fun ex -> printfn $" Error: {ex.Message}" ),
361+ ( fun _cancelled -> printfn " Cancelled" )
362+ )
363+
354364(**
355365## When to Use What
356366
0 commit comments