The type 'bool' is not compatible with the type 'IDisposable'

208 views Asked by At

I am just new to F# programming and I am building a project which contains a F# file and during build there is an error in line 5(progress):


The type 'bool' is not compatible with the type 'IDisposable'


   member private this.Main() = async{
        let! cont = async{
            try
                let! model = async{
   (*Error*)        use! progress = Progress.Show(ctx, LocalDevice.instance.loading)
                    return! load()
                }
                return this.ShowForm(model)
            with err -> 
                do! show_error(err)
                return this.Main()
        }
        return! cont
    }

Does anyone know why this error is coming and what is the solution?

1

There are 1 answers

0
Mark Seemann On BEST ANSWER

You can only use (or use!) something that's IDisposable, which bool isn't (as the compiler error states). Use let! instead:

let! progress = Progress.Show(ctx, LocalDevice.instance.loading)