-
Notifications
You must be signed in to change notification settings - Fork 831
Closed
Closed
Copy link
Labels
Area-AsyncAsync supportAsync supportBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
Description
Please provide a succinct description of the issue.
Given a mailbox, i invoke Dispose on it by (b :> IDisposable).Dispose(). After that it continues to receive and process messages
Provide the steps required to reproduce the problem:
open System
open System.Threading
// Define a function to construct a message to print
type Msg =
| Print of string
[<EntryPoint>]
let main argv =
let mutable skipMessages = false
let inbox =
MailboxProcessor.Start( fun b ->
let rec loop() = async{
match! b.Receive() with
| Print msg ->
if(skipMessages)
then
printfn "skipping message %s" msg
return! loop()
else
do! Async.Sleep 1000
if(skipMessages) then () else
printfn "%s" msg
return! loop()
}
loop()
)
[1..10] |> Seq.iter (fun x -> string x |> Print |> inbox.Post )
async{
do! Async.Sleep 2500
skipMessages <- true
(inbox:>IDisposable).Dispose()
inbox.Post (Print "11")
printfn "Mailbox disposed"
printfn "cts cancelled, queue count %i" inbox.CurrentQueueLength
} |> Async.Start
Console.ReadLine() |> ignore
0 // return an integer exit codeExpected behavior
After dispose is called, mailbox should stop receiving and processing messages
Actual behavior
After dispose is called, message receiving and processing is not stopped
Known workarounds
Add a flag and skip message processing based on its value
Related information
Not related to specific net core or fsharp version
Metadata
Metadata
Assignees
Labels
Area-AsyncAsync supportAsync supportBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Type
Projects
Status
Done